db4o-8.0.184.15484+dfsg/000755 001750 001750 00000000000 11621751105 016126 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/db4o.license.html000644 001750 001750 00000112230 11520622620 021261 0ustar00directhexdirecthex000000 000000 GNU General Public License - GNU Project - Free Software Foundation (FSF)

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble

The GNU General Public License is a free, copyleft license for software and other kinds of works.

The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.

For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.

Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.

Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS

0. Definitions.

“This License” refers to version 3 of the GNU General Public License.

“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.

“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.

To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.

A “covered work” means either the unmodified Program or a work based on the Program.

To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.

To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.

An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.

1. Source Code.

The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.

A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.

The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.

The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.

The Corresponding Source for a work in source code form is that same work.

2. Basic Permissions.

All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.

You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.

Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.

3. Protecting Users' Legal Rights From Anti-Circumvention Law.

No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.

When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.

4. Conveying Verbatim Copies.

You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.

You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.

5. Conveying Modified Source Versions.

You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:

A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.

6. Conveying Non-Source Forms.

You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:

A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.

A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.

“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.

If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).

The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.

Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.

7. Additional Terms.

“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.

When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.

Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:

All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.

If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.

Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.

8. Termination.

You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).

However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.

9. Acceptance Not Required for Having Copies.

You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.

10. Automatic Licensing of Downstream Recipients.

Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.

An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.

You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.

11. Patents.

A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.

A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.

Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.

In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.

If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.

If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.

A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.

Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.

12. No Surrender of Others' Freedom.

If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.

13. Use with the GNU Affero General Public License.

Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.

14. Revised Versions of this License.

The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.

If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.

Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.

15. Disclaimer of Warranty.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

16. Limitation of Liability.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

17. Interpretation of Sections 15 and 16.

If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.

You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

db4o-8.0.184.15484+dfsg/readme.html000644 001750 001750 00000006441 11520622620 020253 0ustar00directhexdirecthex000000 000000 Readme

This distribution contains binaries, sources and documentation for the open source object database db4o in the corresponding folders:

/bin binaries
/doc documentation
/ome Object Manager Enterprise - database browser plugin for your IDE
/src sources

For more information about the content see readme.html file in the corresponding folder.

Getting Started

For the fastest start with db4o please work through the tutorial, available in different formats in the following folder:
./doc/tutorial/
If you are working with db4o for .NET, it is recommended to run the tutorial program:
./doc/tutorial/Db4oTutorial.exe
The PDF tutorial will work best for fulltext search:
./doc/tutorial/db4o-8.0-tutorial.pdf

Join The db4o Community

Join the db4o community for help, tips and tricks.  
Ask for help in the db4o forums at any time.
And take a look at additional resources on the community website.
If you want to stay informed, subscribe to our db4o blogs.

About this software

The software contained in this distribution is the open source object database engine "db4o" supplied by:
Versant Corp.
255 Shoreline Drive
Suite 450
Redwood City, CA 94065
USA
Make sure that you have downloaded the latest version from the db4objects website:
http://www.db4o.com
db4o may be used under the GNU General Public License, GPL. You should have received a copy of the GPL with the download.

Your db4o team. db4o-8.0.184.15484+dfsg/src/000755 001750 001750 00000000000 11621751237 016723 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/000755 001750 001750 00000000000 11520622070 023247 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/Db4objects.Db4o.Optional-Silverlight-2008.csproj000644 001750 001750 00000014223 11520622070 033633 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg Debug AnyCPU 9.0.30729 2.0 {97B6DEA6-255B-4B49-8973-38943AC2E70C} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4objects.Db4o.Optional Db4objects.Db4o.Optional v3.5 false true true true ../db4objects.snk true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o.Optional-CF-2008.csproj000644 001750 001750 00000016153 11520622040 031707 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {667C616E-FEA2-4D5E-93F0-9D18D17275FA} Library Properties Db4objects.Db4o.Optional_CF_2008 Db4objects.Db4o.Optional {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 Db4objects.Db4o.Optional_CF_2008 v3.5 2.0 Pocket PC 2003 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;CF_3_5;CF;$(PlatformFamilyName) prompt 512 4 true true Off bin\Debug\Db4objects.Db4o.Optional.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;CF_3_5;CF;$(PlatformFamilyName) prompt 512 4 true true Off bin\Release\Db4objects.Db4o.Optional.xml 1591;1572;1573;1574;0419; {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/native/000755 001750 001750 00000000000 11520622042 024534 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/000755 001750 001750 00000000000 11520622064 027312 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/000755 001750 001750 00000000000 11520622070 031434 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/Db4oPerformanceCounters.cs000644 001750 001750 00000005575 11520622624 036422 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.Foundation; namespace Db4objects.Db4o.Monitoring { public class Db4oPerformanceCounters { public static readonly string CategoryName = "Db4o"; public static void Install() { if (CategoryExists()) { return; } CounterCreationData[] creationData = CreationDataFor(PerformanceCounterSpec.All()); CounterCreationDataCollection collection = new CounterCreationDataCollection(creationData); PerformanceCounterCategory.Create(CategoryName, "Db4o Performance Counters", PerformanceCounterCategoryType.MultiInstance, collection); } private static CounterCreationData[] CreationDataFor(PerformanceCounterSpec[] performanceCounterSpecs) { CounterCreationData[] creationData = new CounterCreationData[performanceCounterSpecs.Length]; for(int i = 0; i < performanceCounterSpecs.Length; i++) { creationData[i] = performanceCounterSpecs[i].CounterCreationData(); } return creationData; } public static void ReInstall() { if (CategoryExists()) DeleteCategory(); Install(); } public static PerformanceCounter CounterFor(PerformanceCounterSpec spec, bool readOnly) { return CounterFor(spec, My.Instance, readOnly); } internal static PerformanceCounter CounterFor(PerformanceCounterSpec spec, IObjectContainer container, bool readOnly) { return NewDb4oCounter(spec.Id, container.ToString(), readOnly); } public static PerformanceCounter CounterFor(PerformanceCounterSpec spec, IObjectContainer container) { return NewDb4oCounter(spec.Id, container.ToString(), true); } protected static PerformanceCounter NewDb4oCounter(string counterName, string instanceName, bool readOnly) { Install(); PerformanceCounter counter = new PerformanceCounter(CategoryName, counterName, instanceName, readOnly); if (readOnly) return counter; counter.RawValue = 0; return counter; } private static bool CategoryExists() { return PerformanceCounterCategory.Exists(CategoryName); } private static void DeleteCategory() { PerformanceCounterCategory.Delete(CategoryName); } } } #endifsrc/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/IOMonitoringSupport.cs000644 001750 001750 00000002211 11520622624 035657 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.Config; using Db4objects.Db4o.Internal; namespace Db4objects.Db4o.Monitoring { public class IOMonitoringSupport : IConfigurationItem { public void Prepare(IConfiguration configuration) { configuration.Storage = new MonitoredStorage(configuration.Storage); } public void Apply(IInternalObjectContainer container) { } } } #endif src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/ObjectLifecycleMonitoringSupport.cs000644 001750 001750 00000007022 11520622624 040403 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System; using System.Diagnostics; using Db4objects.Db4o.Config; using Db4objects.Db4o.Events; using Db4objects.Db4o.Internal; namespace Db4objects.Db4o.Monitoring { public class ObjectLifecycleMonitoringSupport : IConfigurationItem { public void Prepare(IConfiguration configuration) { } public void Apply(IInternalObjectContainer container) { PerformanceCounter storedObjectsPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsStoredPerSec, false); PerformanceCounter activatedObjectsPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsActivatedPerSec, false); PerformanceCounter deactivatedObjectsPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsDeactivatedPerSec, false); IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container); EventHandler eventHandler = delegate { storedObjectsPerSec.Increment(); }; eventRegistry.Created += eventHandler; eventRegistry.Updated += eventHandler; eventRegistry.Activated += delegate { activatedObjectsPerSec.Increment(); }; eventRegistry.Deactivated += delegate { deactivatedObjectsPerSec.Increment(); }; eventRegistry.Closing += delegate { storedObjectsPerSec.Dispose(); activatedObjectsPerSec.Dispose(); deactivatedObjectsPerSec.Dispose(); storedObjectsPerSec.RemoveInstance(); }; if (container.IsClient) { return; } PerformanceCounter deletedObjectsPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsDeletedPerSec, false); eventRegistry.Deleted += delegate { deletedObjectsPerSec.Increment(); }; eventRegistry.Closing += delegate { deletedObjectsPerSec.Dispose(); }; } } } #endifsrc/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/QueryMonitoringSupport.cs000644 001750 001750 00000012276 11520622624 036471 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System; using System.Diagnostics; using Db4objects.Db4o.Config; using Db4objects.Db4o.Diagnostic; using Db4objects.Db4o.Events; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Config; using Db4objects.Db4o.Internal.Query; #if NET_3_5 using Db4objects.Db4o.Linq; #endif namespace Db4objects.Db4o.Monitoring { public class NativeQueryMonitoringSupport : IConfigurationItem { public void Prepare(IConfiguration configuration) { #if NET_3_5 var common = Db4oLegacyConfigurationBridge.AsCommonConfiguration(configuration); common.Environment.Add(new LinqQueryMonitor()); #endif } public void Apply(IInternalObjectContainer container) { #if NET_3_5 My.Instance.Initialize(); #endif IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container); PerformanceCounter unoptimizedNativeQueriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.UnoptimizedNativeQueriesPerSec, false); PerformanceCounter nativeQueriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.NativeQueriesPerSec, false); container.GetNativeQueryHandler().QueryExecution += delegate(object sender, QueryExecutionEventArgs args) { if (args.ExecutionKind == QueryExecutionKind.Unoptimized) unoptimizedNativeQueriesPerSec.Increment(); nativeQueriesPerSec.Increment(); }; eventRegistry.Closing += delegate { nativeQueriesPerSec.RemoveInstance(); nativeQueriesPerSec.Dispose(); unoptimizedNativeQueriesPerSec.Dispose(); #if NET_3_5 container.WithEnvironment(delegate { My.Instance.Dispose(); }); #endif }; } #if NET_3_5 class LinqQueryMonitor : ILinqQueryMonitor { private PerformanceCounter _queriesPerSec; private PerformanceCounter _unoptimizedQueriesPerSec; public void OnOptimizedQuery() { QueriesPerSec().Increment(); } public void OnUnoptimizedQuery() { QueriesPerSec().Increment(); UnoptimizedQueriesPerSec().Increment(); } public void Dispose() { Close(_queriesPerSec); Close(_unoptimizedQueriesPerSec); } private static void Close(IDisposable counter) { if (null != counter) { counter.Dispose(); } } private PerformanceCounter QueriesPerSec() { return _queriesPerSec; } private PerformanceCounter UnoptimizedQueriesPerSec() { return _unoptimizedQueriesPerSec; } public void Initialize() { _queriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.LinqQueriesPerSec, false); _unoptimizedQueriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.UnoptimizedLinqQueriesPerSec, false); } } #endif } public class QueryMonitoringSupport : IConfigurationItem { public void Prepare(IConfiguration configuration) { } public void Apply(IInternalObjectContainer container) { PerformanceCounter queriesPerSec = null; PerformanceCounter classIndexScansPerSec = null; container.WithEnvironment(delegate { queriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.QueriesPerSec, false); classIndexScansPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ClassIndexScansPerSec, false); }); IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container); eventRegistry.QueryFinished += delegate { queriesPerSec.Increment(); }; container.Configure().Diagnostic().AddListener(new DiagnosticListener(classIndexScansPerSec)); eventRegistry.Closing += delegate { queriesPerSec.RemoveInstance(); classIndexScansPerSec.RemoveInstance(); queriesPerSec.Dispose(); classIndexScansPerSec.Dispose(); }; } class DiagnosticListener : IDiagnosticListener { private readonly PerformanceCounter _classIndexScansPerSec; public DiagnosticListener(PerformanceCounter classIndexScansPerSec) { _classIndexScansPerSec = classIndexScansPerSec; } public void OnDiagnostic(IDiagnostic d) { LoadedFromClassIndex classIndexScan = d as LoadedFromClassIndex; if (classIndexScan == null) return; _classIndexScansPerSec.Increment(); } } } } #endifsrc/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/ReferenceSystemMonitoringSupport.cs000644 001750 001750 00000006516 11520622624 040467 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.Config; using Db4objects.Db4o.Events; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.References; using Db4objects.Db4o.Monitoring.Internal; namespace Db4objects.Db4o.Monitoring { public class ReferenceSystemMonitoringSupport : IConfigurationItem { private class ReferenceSystemListener : IReferenceSystemListener { private PerformanceCounter _performanceCounter; public ReferenceSystemListener(PerformanceCounter counter) { _performanceCounter = counter; _performanceCounter.Disposed += delegate { _performanceCounter = null; }; } public void NotifyReferenceCountChanged(int changedBy) { if (null != _performanceCounter) { _performanceCounter.IncrementBy(changedBy); } } } private class MonitoringSupportReferenceSystemFactory : IReferenceSystemFactory, IDeepClone { internal MonitoringSupportReferenceSystemFactory() { } public IReferenceSystem NewReferenceSystem(IInternalObjectContainer container) { PerformanceCounter counter = ObjectsInReferenceSystemCounterFor(container); return new MonitoringReferenceSystem(new ReferenceSystemListener(counter)); } public object DeepClone(object context) { return new MonitoringSupportReferenceSystemFactory(this); } private PerformanceCounter ObjectsInReferenceSystemCounterFor(IObjectContainer container) { if (_objectsCounter == null) { _objectsCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectReferenceCount, container, false); IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container); eventRegistry.Closing += delegate { _objectsCounter.RemoveInstance(); _objectsCounter.Dispose(); }; } return _objectsCounter; } private MonitoringSupportReferenceSystemFactory(MonitoringSupportReferenceSystemFactory factory) { _objectsCounter = factory._objectsCounter; } private PerformanceCounter _objectsCounter; } public void Prepare(IConfiguration configuration) { ((Config4Impl)configuration).ReferenceSystemFactory(new MonitoringSupportReferenceSystemFactory()); } public void Apply(IInternalObjectContainer container) { } } } #endif src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/FreespaceMonitoringSupport.cs000644 001750 001750 00000011267 11520622624 037260 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.Config; using Db4objects.Db4o.Events; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Freespace; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Monitoring { public class FreespaceMonitoringSupport : IConfigurationItem { public void Prepare(IConfiguration configuration) { } public void Apply(IInternalObjectContainer container) { if(! (container is LocalObjectContainer) || container.ConfigImpl.IsReadOnly()) { return; } LocalObjectContainer localObjectContainer = (LocalObjectContainer) container; IFreespaceManager freespaceManager = localObjectContainer.FreespaceManager(); FreespaceListener freespaceListener = new FreespaceListener(localObjectContainer); freespaceManager.Traverse(new FreespaceInitializingVisitor(freespaceListener)); IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container); eventRegistry.Closing += delegate { freespaceListener.Dispose(); freespaceManager.Listener(NullFreespaceListener.Instance); }; freespaceManager.Listener(freespaceListener); } private class FreespaceInitializingVisitor : IVisitor4 { private readonly IFreespaceListener _freespaceListener; public FreespaceInitializingVisitor(IFreespaceListener listener) { _freespaceListener = listener; } public void Visit(object obj) { Slot slot = (Slot) obj; _freespaceListener.SlotAdded(slot.Length()); } } private class FreespaceListener : IFreespaceListener { public FreespaceListener(IObjectContainer container) { _totalFreespaceCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.TotalFreespace, container, false); _averageSlotSizeCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceAverageSlotSize, container, false); _freespaceSlotsCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceSlotCount, container, false); _reusedSlotsCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceReusedSlotsPerSec, container, false); } public void SlotAdded(int size) { _slotCount++; _totalFreespace += size; AdjustCounters(); } public void SlotRemoved(int size) { _reusedSlotsCounter.Increment(); _slotCount--; _totalFreespace -= size; AdjustCounters(); } private void AdjustCounters() { _totalFreespaceCounter.RawValue = _totalFreespace; _averageSlotSizeCounter.RawValue = AverageSlotSize(_slotCount); _freespaceSlotsCounter.RawValue = _slotCount; } private int AverageSlotSize(int slotCount) { return slotCount == 0 ? 0 : _totalFreespace / slotCount; } public void Dispose() { _totalFreespaceCounter.RemoveInstance(); _totalFreespaceCounter.Dispose(); _averageSlotSizeCounter.Dispose(); _freespaceSlotsCounter.Dispose(); _reusedSlotsCounter.Dispose(); } private readonly PerformanceCounter _totalFreespaceCounter; private readonly PerformanceCounter _averageSlotSizeCounter; private readonly PerformanceCounter _freespaceSlotsCounter; private readonly PerformanceCounter _reusedSlotsCounter; private int _slotCount; private int _totalFreespace; } } } #endifsrc/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/MonitoredStorage.cs000644 001750 001750 00000005423 11520622624 035202 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.IO; namespace Db4objects.Db4o.Monitoring { /// /// Publishes performance counters for bytes read and written. /// public class MonitoredStorage : StorageDecorator { public MonitoredStorage(IStorage storage) : base(storage) { } protected override IBin Decorate(BinConfiguration config, IBin bin) { return new MonitoredBin(bin); } internal class MonitoredBin : BinDecorator { private readonly PerformanceCounter _bytesWrittenCounter; private readonly PerformanceCounter _bytesReadCounter; public MonitoredBin(IBin bin) : base(bin) { _bytesWrittenCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.BytesWrittenPerSec, false); _bytesReadCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.BytesReadPerSec, false); } public override void Write(long position, byte[] bytes, int bytesToWrite) { base.Write(position, bytes, bytesToWrite); _bytesWrittenCounter.IncrementBy(bytesToWrite); } public override int Read(long position, byte[] buffer, int bytesToRead) { int bytesRead = base.Read(position, buffer, bytesToRead); _bytesReadCounter.IncrementBy(bytesRead); return bytesRead; } public override int SyncRead(long position, byte[] bytes, int bytesToRead) { int bytesRead = base.SyncRead(position, bytes, bytesToRead); _bytesReadCounter.IncrementBy(bytesRead); return bytesRead; } public override void Close() { base.Close(); _bytesReadCounter.RemoveInstance(); _bytesReadCounter.Dispose(); _bytesWrittenCounter.Dispose(); } } } } #endifsrc/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Monitoring/PerformanceCounterSpec.cs000644 001750 001750 00000022053 11520622624 036327 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.Foundation; namespace Db4objects.Db4o.Monitoring { public class PerformanceCounterSpec { private readonly string _id; private readonly string _description; private readonly PerformanceCounterType _counterType; private PerformanceCounterSpec(string id, string description, PerformanceCounterType counterType) { _id = id; _description = description; _counterType = counterType; } public static readonly PerformanceCounterSpec BytesWrittenPerSec = new PerformanceCounterSpec("bytes written/sec", "Bytes written per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec BytesReadPerSec = new PerformanceCounterSpec("bytes read/sec", "Bytes read per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec ObjectsStoredPerSec = new PerformanceCounterSpec("objects stored/sec", "Number of objects stored per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec ObjectsDeletedPerSec = new PerformanceCounterSpec("objects deleted/sec", "Number of objects deleted per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec ObjectsActivatedPerSec = new PerformanceCounterSpec("objects activated/sec", "Number of objects activated per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec ObjectsDeactivatedPerSec = new PerformanceCounterSpec("objects deactivated/sec", "Number of objects deactivated per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec QueriesPerSec = new PerformanceCounterSpec("queries/sec", "Number of queries executed per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec ClassIndexScansPerSec = new PerformanceCounterSpec("class index scans/sec", "Number of queries that could not use field indexes and had to fall back to class index scans per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec NativeQueriesPerSec = new PerformanceCounterSpec("native queries/sec", "Number of native queries executed per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec UnoptimizedNativeQueriesPerSec = new PerformanceCounterSpec("unoptimized native queries/sec", "Number of unoptimized native queries executed per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec NetBytesSentPerSec = new PerformanceCounterSpec("network bytes sent/sec", "Number of bytes sent per second through the socket layer", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec NetBytesReceivedPerSec = new PerformanceCounterSpec("network bytes received/sec", "Number of bytes received per second through the socket layer", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec NetMessagesSentPerSec = new PerformanceCounterSpec("network messages sent/sec", "Number of messages per second through the socket layer", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec NetClientConnections = new PerformanceCounterSpec("number of connected clients", "Number of connected clients", PerformanceCounterType.NumberOfItems32); public static readonly PerformanceCounterSpec FreespaceAverageSlotSize = new PerformanceCounterSpec("average freespace slot size", "Average freespace slot size in bytes", PerformanceCounterType.NumberOfItems32); public static readonly PerformanceCounterSpec FreespaceReusedSlotsPerSec = new PerformanceCounterSpec("reused freespace slots/sec", "Reused freespace slots per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec FreespaceSlotCount = new PerformanceCounterSpec("number of freespace slots", "Number of freespace slots", PerformanceCounterType.NumberOfItems32); public static readonly PerformanceCounterSpec TotalFreespace = new PerformanceCounterSpec("total freespace", "Total freespace in bytes", PerformanceCounterType.NumberOfItems32); public static PerformanceCounterSpec ObjectReferenceCount = new PerformanceCounterSpec("number of object references", "Number of object references", PerformanceCounterType.NumberOfItems32); #if NET_3_5 public static readonly PerformanceCounterSpec LinqQueriesPerSec = new PerformanceCounterSpec("linq queries/sec", "Number of Linq queries executed per second", PerformanceCounterType.RateOfCountsPerSecond32); public static readonly PerformanceCounterSpec UnoptimizedLinqQueriesPerSec = new PerformanceCounterSpec("unoptimized linq queries/sec", "Number of unoptimized Linq queries executed per second", PerformanceCounterType.RateOfCountsPerSecond32); #endif public string Id { get { return _id; } } public static PerformanceCounterSpec[] All() { return new PerformanceCounterSpec[] { BytesWrittenPerSec, BytesReadPerSec, ObjectsStoredPerSec, ObjectsDeletedPerSec, ObjectsActivatedPerSec, ObjectsDeactivatedPerSec, QueriesPerSec, ClassIndexScansPerSec, NativeQueriesPerSec, UnoptimizedNativeQueriesPerSec, NetBytesSentPerSec, NetBytesReceivedPerSec, NetMessagesSentPerSec, NetClientConnections, FreespaceAverageSlotSize, FreespaceReusedSlotsPerSec, FreespaceSlotCount, TotalFreespace, ObjectReferenceCount, #if NET_3_5 LinqQueriesPerSec, UnoptimizedLinqQueriesPerSec, #endif }; } public CounterCreationData CounterCreationData() { return new CounterCreationData(_id, _description, _counterType); } public PerformanceCounter PerformanceCounter(IObjectContainer container) { return Db4oPerformanceCounters.CounterFor(this, container, true); } public PerformanceCounter PerformanceCounter() { return PerformanceCounter(My.Instance); } } } #endifdb4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Filestats/000755 001750 001750 00000000000 11520622064 031250 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Filestats/FileUsageStatsCollector.cs000644 001750 001750 00000001771 11520622624 036262 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using Db4objects.Db4o.Internal.Collections; namespace Db4objects.Db4o.Filestats { public partial class FileUsageStatsCollector { private void RegisterBigSetCollector() { MiscCollectors[typeof(BigSet<>).FullName] = new BigSetMiscCollector(); } } } #endifdb4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Config/000755 001750 001750 00000000000 11520622054 030516 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/native/Db4objects.Db4o/Config/JavaSupport.cs000644 001750 001750 00000007155 11520622624 033336 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Config { [Obsolete("Since 8.0")] public class JavaSupport : IConfigurationItem { public void Prepare(IConfiguration config) { AddDb4OBasicAliases(config); AddExceptionAliases(config); AddQueryAliases(config); AddCollectionAliases(config); AddClientServerAliases(config); config.ObjectClass("java.lang.Class").Translate(new TType()); } private static void AddDb4OBasicAliases(IConfiguration config) { config.AddAlias(new WildcardAlias("com.db4o.ext.*", "Db4objects.Db4o.Ext.*, Db4objects.Db4o")); config.AddAlias(new TypeAlias("com.db4o.StaticField", FullyQualifiedName(typeof(StaticField)))); config.AddAlias(new TypeAlias("com.db4o.StaticClass", FullyQualifiedName(typeof(StaticClass)))); } private static void AddCollectionAliases(IConfiguration config) { config.AddAlias(new TypeAlias("com.db4o.foundation.Collection4", FullyQualifiedName(typeof(Collection4)))); config.AddAlias(new TypeAlias("com.db4o.foundation.List4", FullyQualifiedName(typeof(List4)))); } private static void AddClientServerAliases(IConfiguration config) { #if !SILVERLIGHT config.AddAlias(new TypeAlias("com.db4o.User", FullyQualifiedName(typeof(User)))); config.AddAlias(new TypeAlias("com.db4o.cs.internal.messages.MUserMessage$UserMessagePayload", "Db4objects.Db4o.CS.Internal.Messages.MUserMessage+UserMessagePayload, Db4objects.Db4o.CS")); config.AddAlias(new TypeAlias("com.db4o.internal.TransportObjectContainer$KnownObjectIdentity", "Db4objects.Db4o.Internal.TransportObjectContainer+KnownObjectIdentity, Db4objects.Db4o")); config.AddAlias(new WildcardAlias("com.db4o.cs.internal.*", "Db4objects.Db4o.CS.Internal.*, Db4objects.Db4o.CS")); #endif } private static void AddQueryAliases(IConfiguration config) { config.AddAlias(new TypeAlias("com.db4o.query.Evaluation", FullyQualifiedName(typeof(IEvaluation)))); config.AddAlias(new TypeAlias("com.db4o.query.Candidate", FullyQualifiedName(typeof(ICandidate)))); config.AddAlias(new WildcardAlias("com.db4o.internal.query.processor.*", "Db4objects.Db4o.Internal.Query.Processor.*, Db4objects.Db4o")); } private static void AddExceptionAliases(IConfiguration config) { config.AddAlias(new TypeAlias("com.db4o.foundation.ChainedRuntimeException", FullyQualifiedName(typeof(Exception)))); config.AddAlias(new TypeAlias("java.lang.Throwable", FullyQualifiedName(typeof(Exception)))); config.AddAlias(new TypeAlias("java.lang.RuntimeException", FullyQualifiedName(typeof(Exception)))); config.AddAlias(new TypeAlias("java.lang.Exception", FullyQualifiedName(typeof(Exception)))); } private static string FullyQualifiedName(Type type) { return ReflectPlatform.FullyQualifiedName(type); } public void Apply(IInternalObjectContainer container) { } } } src/Db4objects.Db4o.Optional/Db4objects.Db4o.Optional-Silverlight-2010.csproj000644 001750 001750 00000015341 11520622070 033626 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg v3.5 true ../db4objects.snk Debug AnyCPU 9.0.30729 2.0 {97B6DEA6-255B-4B49-8973-38943AC2E70C} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4objects.Db4o.Optional Db4objects.Db4o.Optional v4.0 false true true true ../db4objects.snk Silverlight $(TargetFrameworkVersion) 3.5 true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o.Optional-2008.csproj000644 001750 001750 00000015530 11520622042 031421 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {E9588FE7-C19D-445E-BB53-AE539EA4F0E6} Library Properties Db4objects.Db4o.Optional Db4objects.Db4o.Optional 2.0 v3.5 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;POLL_SOCKET;NET_3_5 prompt 4 bin\Debug\Db4objects.Db4o.Optional.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;NET_3_5 prompt 4 bin\Release\Db4objects.Db4o.Optional.xml 1591;1572;1573;1574;0419; False ..\Libs\net-2.0\Cecil.FlowAnalysis.dll False ..\Libs\net-2.0\Mono.Cecil.dll 3.5 {23531440-0922-43EB-A483-6592FFC2F093} Db4objects.Db4o.Linq-2008 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o.Optional-2010.csproj000644 001750 001750 00000020366 11520622042 031415 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {E9588FE7-C19D-445E-BB53-AE539EA4F0E6} Library Properties Db4objects.Db4o.Optional Db4objects.Db4o.Optional 3.5 v4.0 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;POLL_SOCKET;NET_3_5;NET_4_0 prompt 4 bin\Debug\Db4objects.Db4o.Optional.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;POLL_SOCKET;NET_3_5;NET_4_0 prompt 4 bin\Release\Db4objects.Db4o.Optional.xml 1591;1572;1573;1574;0419; False ..\Libs\net-2.0\Cecil.FlowAnalysis.dll False ..\Libs\net-2.0\Mono.Cecil.dll 3.5 False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {23531440-0922-43EB-A483-6592FFC2F093} Db4objects.Db4o.Linq-2010 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/000755 001750 001750 00000000000 11520622054 026023 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Monitoring/000755 001750 001750 00000000000 11520622054 030150 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/Db4objects.Db4o/Monitoring/IReferenceSystemListener.cs000644 001750 001750 00000001525 11520622624 035350 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Monitoring { /// public interface IReferenceSystemListener { void NotifyReferenceCountChanged(int changedBy); } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Monitoring/Internal/000755 001750 001750 00000000000 11520622044 031723 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/Db4objects.Db4o/Monitoring/Internal/MonitoringReferenceSystem.cs000644 001750 001750 00000007216 11520622624 037356 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.References; using Db4objects.Db4o.Monitoring; namespace Db4objects.Db4o.Monitoring.Internal { /// public class MonitoringReferenceSystem : TransactionalReferenceSystemBase, IReferenceSystem { private readonly IReferenceSystemListener _referenceSystemListener; private int _referenceCount; public MonitoringReferenceSystem(IReferenceSystemListener referenceSystem) { _referenceSystemListener = referenceSystem; } public override void Commit() { IntByRef removedReferenceCount = new IntByRef(); TraverseNewReferences(new _IVisitor4_26(this, removedReferenceCount)); CreateNewReferences(); ReferenceCountChanged(-removedReferenceCount.value); } private sealed class _IVisitor4_26 : IVisitor4 { public _IVisitor4_26(MonitoringReferenceSystem _enclosing, IntByRef removedReferenceCount ) { this._enclosing = _enclosing; this.removedReferenceCount = removedReferenceCount; } public void Visit(object obj) { ObjectReference oref = (ObjectReference)obj; if (oref.GetObject() != null) { this._enclosing._committedReferences.AddExistingReference(oref); } else { removedReferenceCount.value++; } } private readonly MonitoringReferenceSystem _enclosing; private readonly IntByRef removedReferenceCount; } public override void AddExistingReference(ObjectReference @ref) { _committedReferences.AddExistingReference(@ref); ReferenceCountChanged(1); } public override void AddNewReference(ObjectReference @ref) { _newReferences.AddNewReference(@ref); ReferenceCountChanged(1); } public override void RemoveReference(ObjectReference @ref) { if (_newReferences.ReferenceForId(@ref.GetID()) != null) { _newReferences.RemoveReference(@ref); ReferenceCountChanged(-1); } if (_committedReferences.ReferenceForId(@ref.GetID()) != null) { _committedReferences.RemoveReference(@ref); ReferenceCountChanged(-1); } } public override void Rollback() { IntByRef newReferencesCount = new IntByRef(); TraverseNewReferences(new _IVisitor4_63(newReferencesCount)); CreateNewReferences(); ReferenceCountChanged(-newReferencesCount.value); } private sealed class _IVisitor4_63 : IVisitor4 { public _IVisitor4_63(IntByRef newReferencesCount) { this.newReferencesCount = newReferencesCount; } public void Visit(object obj) { newReferencesCount.value++; } private readonly IntByRef newReferencesCount; } private void ReferenceCountChanged(int changedBy) { if (changedBy == 0) { return; } _referenceCount += changedBy; _referenceSystemListener.NotifyReferenceCountChanged(changedBy); } public virtual void Discarded() { ReferenceCountChanged(-_referenceCount); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/000755 001750 001750 00000000000 11520622070 027757 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/ClassNode.cs000644 001750 001750 00000005473 11520622624 032177 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System.Collections; using Db4objects.Db4o.Internal; using Sharpen.Util; namespace Db4objects.Db4o.Filestats { /// public class ClassNode { public static Sharpen.Util.ISet BuildHierarchy(ClassMetadataRepository repository ) { ClassMetadataIterator classIter = repository.Iterator(); IDictionary nodes = new Hashtable(); Sharpen.Util.ISet roots = new HashSet(); while (classIter.MoveNext()) { Db4objects.Db4o.Internal.ClassMetadata clazz = classIter.CurrentClass(); Db4objects.Db4o.Filestats.ClassNode node = new Db4objects.Db4o.Filestats.ClassNode (clazz); nodes[clazz.GetName()] = node; if (clazz.GetAncestor() == null) { roots.Add(node); } } for (IEnumerator nodeIter = nodes.Values.GetEnumerator(); nodeIter.MoveNext(); ) { Db4objects.Db4o.Filestats.ClassNode node = ((Db4objects.Db4o.Filestats.ClassNode) nodeIter.Current); Db4objects.Db4o.Internal.ClassMetadata ancestor = node.ClassMetadata().GetAncestor (); if (ancestor != null) { ((Db4objects.Db4o.Filestats.ClassNode)nodes[ancestor.GetName()]).AddSubClass(node ); } } return roots; } private readonly Db4objects.Db4o.Internal.ClassMetadata _clazz; private readonly Sharpen.Util.ISet _subClasses = new HashSet(); public ClassNode(Db4objects.Db4o.Internal.ClassMetadata clazz) { _clazz = clazz; } public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() { return _clazz; } internal virtual void AddSubClass(Db4objects.Db4o.Filestats.ClassNode node) { _subClasses.Add(node); } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj == null || GetType() != obj.GetType()) { return false; } return _clazz.GetName().Equals(((Db4objects.Db4o.Filestats.ClassNode)obj)._clazz. GetName()); } public override int GetHashCode() { return _clazz.GetName().GetHashCode(); } public virtual IEnumerable SubClasses() { return _subClasses; } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/FileUsageStatsUtil.cs000644 001750 001750 00000002333 11520622624 034035 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT namespace Db4objects.Db4o.Filestats { /// public sealed class FileUsageStatsUtil { private static readonly string Padding = " "; private FileUsageStatsUtil() { } public static string FormatLine(string label, long amount) { return PadLeft(label, 20) + ": " + PadLeft(amount.ToString(), 12) + "\n"; } private static string PadLeft(string val, int len) { return Sharpen.Runtime.Substring(Padding, 0, len - val.Length) + val; } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/SlotMapImpl.cs000644 001750 001750 00000007460 11520622624 032523 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System.Collections; using System.Text; using Db4objects.Db4o.Filestats; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Filestats { /// public class SlotMapImpl : ISlotMap { private TreeIntObject _slots = null; private readonly long _fileLength; public SlotMapImpl(long fileLength) { _fileLength = fileLength; } public virtual void Add(Slot slot) { _slots = ((TreeIntObject)Tree.Add(_slots, new TreeIntObject(slot.Address(), slot) )); } public virtual IList Merged() { IList mergedSlots = new ArrayList(); ByRef mergedSlot = ByRef.NewInstance(new Slot(0, 0)); Tree.Traverse(_slots, new _IVisitor4_32(mergedSlot, mergedSlots)); mergedSlots.Add(((Slot)mergedSlot.value)); return mergedSlots; } private sealed class _IVisitor4_32 : IVisitor4 { public _IVisitor4_32(ByRef mergedSlot, IList mergedSlots) { this.mergedSlot = mergedSlot; this.mergedSlots = mergedSlots; } public void Visit(object node) { Slot curSlot = ((Slot)((TreeIntObject)node)._object); if (((Slot)mergedSlot.value).Address() + ((Slot)mergedSlot.value).Length() == curSlot .Address()) { mergedSlot.value = new Slot(((Slot)mergedSlot.value).Address(), ((Slot)mergedSlot .value).Length() + curSlot.Length()); } else { mergedSlots.Add(((Slot)mergedSlot.value)); mergedSlot.value = curSlot; } } private readonly ByRef mergedSlot; private readonly IList mergedSlots; } public virtual IList Gaps(long length) { IList merged = Merged(); IList gaps = new ArrayList(); if (merged.Count == 0) { return gaps; } bool isFirst = true; Slot prevSlot = null; for (IEnumerator curSlotIter = merged.GetEnumerator(); curSlotIter.MoveNext(); ) { Slot curSlot = ((Slot)curSlotIter.Current); if (isFirst) { prevSlot = curSlot; if (prevSlot.Address() > 0) { gaps.Add(new Slot(0, prevSlot.Address())); } isFirst = false; } else { int gapStart = prevSlot.Address() + prevSlot.Length(); gaps.Add(new Slot(gapStart, curSlot.Address() - gapStart)); prevSlot = curSlot; } } int afterlast = prevSlot.Address() + prevSlot.Length(); if (afterlast < length) { gaps.Add(new Slot(afterlast, (int)(length - afterlast))); } return gaps; } public override string ToString() { StringBuilder str = new StringBuilder(); str.Append("SLOTS:\n"); LogSlots(Merged(), str); str.Append("GAPS:"); LogSlots(Gaps(_fileLength), str); return str.ToString(); } private void LogSlots(IEnumerable slots, StringBuilder str) { int totalLength = 0; for (IEnumerator gapIter = slots.GetEnumerator(); gapIter.MoveNext(); ) { Slot gap = ((Slot)gapIter.Current); totalLength += gap.Length(); str.Append(gap).Append("\n"); } str.Append("TOTAL: ").Append(totalLength).Append("\n"); } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/ISlotMap.cs000644 001750 001750 00000001711 11520622624 032003 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System.Collections; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Filestats { /// public interface ISlotMap { void Add(Slot slot); IList Merged(); IList Gaps(long length); } } #endif // !SILVERLIGHT src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/BigSetMiscCollector.cs000644 001750 001750 00000002350 11520622624 034074 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using Db4objects.Db4o.Filestats; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Btree; namespace Db4objects.Db4o.Filestats { /// internal class BigSetMiscCollector : IMiscCollector { public virtual long CollectFor(LocalObjectContainer db, int id, ISlotMap slotMap) { object bigSet = db.GetByID(id); db.Activate(bigSet, 1); BTree btree = (BTree)Reflection4.GetFieldValue(bigSet, "_bTree"); return FileUsageStatsCollector.BTreeUsage(db, btree, slotMap); } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/ClassUsageStats.cs000644 001750 001750 00000006643 11520622624 033375 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System.Text; using Db4objects.Db4o.Filestats; namespace Db4objects.Db4o.Filestats { /// Statistics for the byte usage for a single class (instances, indices, etc.) in a db4o database file. /// /// Statistics for the byte usage for a single class (instances, indices, etc.) in a db4o database file. /// /// public class ClassUsageStats { private readonly string _className; private readonly long _slotUsage; private readonly long _classIndexUsage; private readonly long _fieldIndexUsage; private readonly long _miscUsage; internal ClassUsageStats(string className, long slotSpace, long classIndexUsage, long fieldIndexUsage, long miscUsage) { _className = className; _slotUsage = slotSpace; _classIndexUsage = classIndexUsage; _fieldIndexUsage = fieldIndexUsage; _miscUsage = miscUsage; } /// the name of the persistent class public virtual string ClassName() { return _className; } /// number of bytes used slots containing the actual class instances public virtual long SlotUsage() { return _slotUsage; } /// number of bytes used for the index of class instances public virtual long ClassIndexUsage() { return _classIndexUsage; } /// number of bytes used for field indexes, if any public virtual long FieldIndexUsage() { return _fieldIndexUsage; } /// /// number of bytes used for features that are specific to this class (ex.: the BTree encapsulated within a /// Db4objects.Db4o.Internal.Collections.BigSet<E> /// /// instance) /// public virtual long MiscUsage() { return _miscUsage; } /// aggregated byte usage for this persistent class public virtual long TotalUsage() { return _slotUsage + _classIndexUsage + _fieldIndexUsage + _miscUsage; } public override string ToString() { StringBuilder str = new StringBuilder(); ToString(str); return str.ToString(); } internal virtual void ToString(StringBuilder str) { str.Append(ClassName()).Append("\n"); str.Append(FileUsageStatsUtil.FormatLine("Slots", SlotUsage())); str.Append(FileUsageStatsUtil.FormatLine("Class index", ClassIndexUsage())); str.Append(FileUsageStatsUtil.FormatLine("Field indices", FieldIndexUsage())); if (MiscUsage() > 0) { str.Append(FileUsageStatsUtil.FormatLine("Misc", MiscUsage())); } str.Append(FileUsageStatsUtil.FormatLine("Total", TotalUsage())); } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/NullSlotMap.cs000644 001750 001750 00000002277 11520622624 032535 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System.Collections; using Db4objects.Db4o.Filestats; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Filestats { /// public class NullSlotMap : ISlotMap { public virtual void Add(Slot slot) { } public virtual IList Merged() { return new ArrayList(); } public virtual IList Gaps(long length) { return new ArrayList(); } public override string ToString() { return string.Empty; } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/MiscCollector.cs000644 001750 001750 00000001716 11520622624 033062 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using Db4objects.Db4o.Filestats; using Db4objects.Db4o.Internal; namespace Db4objects.Db4o.Filestats { /// internal interface IMiscCollector { long CollectFor(LocalObjectContainer db, int id, ISlotMap slotMap); } } #endif // !SILVERLIGHT src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/FileUsageStatsCollector.cs000644 001750 001750 00000032341 11520622624 034771 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System; using System.Collections; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Filestats; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Btree; using Db4objects.Db4o.Internal.Classindex; using Db4objects.Db4o.Internal.Fileheader; using Db4objects.Db4o.Internal.Freespace; using Db4objects.Db4o.Internal.Ids; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Filestats { /// /// Collects database file usage statistics and prints them /// to the console. /// /// /// Collects database file usage statistics and prints them /// to the console. /// public partial class FileUsageStatsCollector { private readonly IDictionary MiscCollectors; /// Usage: FileUsageStatsCollector [] public static void Main(string[] args) { string dbPath = args[0]; bool collectSlots = args.Length > 1 && "true".Equals(args[1]); Sharpen.Runtime.Out.WriteLine(dbPath + ": " + new Sharpen.IO.File(dbPath).Length( )); FileUsageStats stats = RunStats(dbPath, collectSlots); Sharpen.Runtime.Out.WriteLine(stats); } public static FileUsageStats RunStats(string dbPath) { return RunStats(dbPath, false); } public static FileUsageStats RunStats(string dbPath, bool collectSlots) { return RunStats(dbPath, collectSlots, Db4oEmbedded.NewConfiguration()); } public static FileUsageStats RunStats(string dbPath, bool collectSlots, IEmbeddedConfiguration config) { IEmbeddedObjectContainer db = Db4oEmbedded.OpenFile(config, dbPath); try { return new Db4objects.Db4o.Filestats.FileUsageStatsCollector(db, collectSlots).CollectStats (); } finally { db.Close(); } } private readonly LocalObjectContainer _db; private FileUsageStats _stats; private IBlockConverter _blockConverter; private readonly ISlotMap _slots; public FileUsageStatsCollector(IObjectContainer db, bool collectSlots) { MiscCollectors = new Hashtable(); RegisterBigSetCollector(); _db = (LocalObjectContainer)db; byte blockSize = _db.BlockSize(); _blockConverter = blockSize > 1 ? (IBlockConverter)new BlockSizeBlockConverter(blockSize ) : (IBlockConverter)new DisabledBlockConverter(); _slots = collectSlots ? (ISlotMap)new SlotMapImpl(_db.FileLength()) : (ISlotMap)new NullSlotMap(); } public virtual FileUsageStats CollectStats() { _stats = new FileUsageStats(_db.FileLength(), FileHeaderUsage(), IdSystemUsage(), Freespace(), ClassMetadataUsage(), FreespaceUsage(), UuidUsage(), _slots, CommitTimestampUsage ()); Sharpen.Util.ISet classRoots = ClassNode.BuildHierarchy(_db.ClassCollection()); for (IEnumerator classRootIter = classRoots.GetEnumerator(); classRootIter.MoveNext (); ) { ClassNode classRoot = ((ClassNode)classRootIter.Current); CollectClassSlots(classRoot.ClassMetadata()); CollectClassStats(_stats, classRoot); } return _stats; } private long CollectClassStats(FileUsageStats stats, ClassNode classNode) { long subClassSlotUsage = 0; for (IEnumerator curSubClassIter = classNode.SubClasses().GetEnumerator(); curSubClassIter .MoveNext(); ) { ClassNode curSubClass = ((ClassNode)curSubClassIter.Current); subClassSlotUsage += CollectClassStats(stats, curSubClass); } ClassMetadata clazz = classNode.ClassMetadata(); long classIndexUsage = 0; if (clazz.HasClassIndex()) { classIndexUsage = BTreeUsage(((BTreeClassIndexStrategy)clazz.Index()).Btree()); } long fieldIndexUsage = FieldIndexUsage(clazz); FileUsageStatsCollector.InstanceUsage instanceUsage = ClassSlotUsage(clazz); long totalSlotUsage = instanceUsage.slotUsage; long ownSlotUsage = totalSlotUsage - subClassSlotUsage; ClassUsageStats classStats = new ClassUsageStats(clazz.GetName(), ownSlotUsage, classIndexUsage , fieldIndexUsage, instanceUsage.miscUsage); stats.AddClassStats(classStats); return totalSlotUsage; } private long FieldIndexUsage(ClassMetadata classMetadata) { LongByRef usage = new LongByRef(); classMetadata.TraverseDeclaredFields(new _IProcedure4_125(this, usage)); return usage.value; } private sealed class _IProcedure4_125 : IProcedure4 { public _IProcedure4_125(FileUsageStatsCollector _enclosing, LongByRef usage) { this._enclosing = _enclosing; this.usage = usage; } public void Apply(object field) { if (((FieldMetadata)field).IsVirtual() || !((FieldMetadata)field).HasIndex()) { return; } usage.value += this._enclosing.BTreeUsage(((FieldMetadata)field).GetIndex(this._enclosing ._db.SystemTransaction())); } private readonly FileUsageStatsCollector _enclosing; private readonly LongByRef usage; } private long BTreeUsage(BTree btree) { return BTreeUsage(_db, btree, _slots); } internal static long BTreeUsage(LocalObjectContainer db, BTree btree, ISlotMap slotMap ) { return BTreeUsage(db.SystemTransaction(), db.IdSystem(), btree, slotMap); } private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree btree, ISlotMap slotMap) { IEnumerator nodeIter = btree.AllNodeIds(transaction); Db4objects.Db4o.Internal.Slots.Slot btreeSlot = idSystem.CommittedSlot(btree.GetID ()); slotMap.Add(btreeSlot); long usage = btreeSlot.Length(); while (nodeIter.MoveNext()) { int curNodeId = ((int)nodeIter.Current); Db4objects.Db4o.Internal.Slots.Slot slot = idSystem.CommittedSlot(curNodeId); slotMap.Add(slot); usage += slot.Length(); } return usage; } private FileUsageStatsCollector.InstanceUsage ClassSlotUsage(ClassMetadata clazz) { if (!clazz.HasClassIndex()) { return new FileUsageStatsCollector.InstanceUsage(0, 0); } IMiscCollector miscCollector = ((IMiscCollector)MiscCollectors[clazz.GetName()]); LongByRef slotUsage = new LongByRef(); LongByRef miscUsage = new LongByRef(); BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index(); index.TraverseAll(_db.SystemTransaction(), new _IVisitor4_166(this, slotUsage, miscCollector , miscUsage)); return new FileUsageStatsCollector.InstanceUsage(slotUsage.value, miscUsage.value ); } private sealed class _IVisitor4_166 : IVisitor4 { public _IVisitor4_166(FileUsageStatsCollector _enclosing, LongByRef slotUsage, IMiscCollector miscCollector, LongByRef miscUsage) { this._enclosing = _enclosing; this.slotUsage = slotUsage; this.miscCollector = miscCollector; this.miscUsage = miscUsage; } public void Visit(object id) { slotUsage.value += this._enclosing.SlotSizeForId((((int)id))); if (miscCollector != null) { miscUsage.value += miscCollector.CollectFor(this._enclosing._db, (((int)id)), this ._enclosing._slots); } } private readonly FileUsageStatsCollector _enclosing; private readonly LongByRef slotUsage; private readonly IMiscCollector miscCollector; private readonly LongByRef miscUsage; } private void CollectClassSlots(ClassMetadata clazz) { if (!clazz.HasClassIndex()) { return; } BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index(); index.TraverseAll(_db.SystemTransaction(), new _IVisitor4_182(this)); } private sealed class _IVisitor4_182 : IVisitor4 { public _IVisitor4_182(FileUsageStatsCollector _enclosing) { this._enclosing = _enclosing; } public void Visit(object id) { this._enclosing._slots.Add(this._enclosing.Slot((((int)id)))); } private readonly FileUsageStatsCollector _enclosing; } private long Freespace() { _db.FreespaceManager().Traverse(new _IVisitor4_190(this)); return _db.FreespaceManager().TotalFreespace(); } private sealed class _IVisitor4_190 : IVisitor4 { public _IVisitor4_190(FileUsageStatsCollector _enclosing) { this._enclosing = _enclosing; } public void Visit(object slot) { this._enclosing._slots.Add(((Db4objects.Db4o.Internal.Slots.Slot)slot)); } private readonly FileUsageStatsCollector _enclosing; } private long FreespaceUsage() { return FreespaceUsage(_db.FreespaceManager()); } private long FreespaceUsage(IFreespaceManager fsm) { if (fsm is InMemoryFreespaceManager) { return 0; } if (fsm is BTreeFreespaceManager) { return BTreeUsage((BTree)FieldValue(fsm, "_slotsByAddress")) + BTreeUsage((BTree) FieldValue(fsm, "_slotsByLength")); } if (fsm is BlockAwareFreespaceManager) { return FreespaceUsage((IFreespaceManager)FieldValue(fsm, "_delegate")); } throw new InvalidOperationException("Unknown freespace manager: " + fsm); } private long IdSystemUsage() { IIdSystem idSystem = _db.IdSystem(); long usage = 0; while (idSystem is BTreeIdSystem) { IIdSystem parentIdSystem = ((IIdSystem)FieldValue(idSystem, "_parentIdSystem")); usage += BTreeUsage(_db.SystemTransaction(), parentIdSystem, (BTree)FieldValue(idSystem , "_bTree"), _slots); PersistentIntegerArray persistentState = (PersistentIntegerArray)FieldValue(idSystem , "_persistentState"); int persistentStateId = persistentState.GetID(); Db4objects.Db4o.Internal.Slots.Slot persistentStateSlot = parentIdSystem.CommittedSlot (persistentStateId); _slots.Add(persistentStateSlot); usage += persistentStateSlot.Length(); idSystem = parentIdSystem; } if (idSystem is InMemoryIdSystem) { Db4objects.Db4o.Internal.Slots.Slot idSystemSlot = ((Db4objects.Db4o.Internal.Slots.Slot )FieldValue(idSystem, "_slot")); usage += idSystemSlot.Length(); _slots.Add(idSystemSlot); } return usage; } private long ClassMetadataUsage() { Db4objects.Db4o.Internal.Slots.Slot classRepositorySlot = Slot(_db.ClassCollection ().GetID()); _slots.Add(classRepositorySlot); long usage = classRepositorySlot.Length(); IEnumerator classIdIter = _db.ClassCollection().Ids(); while (classIdIter.MoveNext()) { int curClassId = (((int)classIdIter.Current)); Db4objects.Db4o.Internal.Slots.Slot classSlot = Slot(curClassId); _slots.Add(classSlot); usage += classSlot.Length(); } return usage; } private long FileHeaderUsage() { int headerLength = _db.GetFileHeader().Length(); int usage = _blockConverter.BlockAlignedBytes(headerLength); FileHeaderVariablePart2 variablePart = (FileHeaderVariablePart2)FieldValue(_db.GetFileHeader (), "_variablePart"); usage += _blockConverter.BlockAlignedBytes(variablePart.MarshalledLength()); _slots.Add(new Db4objects.Db4o.Internal.Slots.Slot(0, headerLength)); _slots.Add(new Db4objects.Db4o.Internal.Slots.Slot(variablePart.Address(), variablePart .MarshalledLength())); return usage; } private long UuidUsage() { if (_db.SystemData().UuidIndexId() <= 0) { return 0; } BTree index = _db.UUIDIndex().GetIndex(_db.SystemTransaction()); return index == null ? 0 : BTreeUsage(index); } private long CommitTimestampUsage() { LocalTransaction st = (LocalTransaction)_db.SystemTransaction(); CommitTimestampSupport commitTimestampSupport = st.CommitTimestampSupport(); if (commitTimestampSupport == null) { return 0; } BTree idToTimestampBtree = commitTimestampSupport.IdToTimestamp(); long idToTimestampBTreeSize = idToTimestampBtree == null ? 0 : BTreeUsage(idToTimestampBtree ); BTree timestampToIdBtree = commitTimestampSupport.TimestampToId(); long timestampToIdBTreeSize = timestampToIdBtree == null ? 0 : BTreeUsage(timestampToIdBtree ); return idToTimestampBTreeSize + timestampToIdBTreeSize; } private int SlotSizeForId(int id) { return Slot(id).Length(); } private static object FieldValue(object parent, string fieldName) { return (object)Reflection4.GetFieldValue(parent, fieldName); } private class InstanceUsage { public readonly long slotUsage; public readonly long miscUsage; public InstanceUsage(long slotUsage, long miscUsage) { this.slotUsage = slotUsage; this.miscUsage = miscUsage; } } private Slot Slot(int id) { return _db.IdSystem().CommittedSlot(id); } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Filestats/FileUsageStats.cs000644 001750 001750 00000014324 11520622624 033202 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System.Collections; using System.Text; using Db4objects.Db4o.Filestats; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Filestats { /// Byte usage statistics for a db4o database file public class FileUsageStats { private TreeStringObject _classUsageStats = null; private long _fileSize; private readonly long _fileHeader; private readonly long _freespace; private readonly long _idSystem; private readonly long _classMetadata; private readonly long _freespaceUsage; private readonly long _uuidUsage; private readonly long _commitTimestampUsage; private readonly ISlotMap _slots; internal FileUsageStats(long fileSize, long fileHeader, long idSystem, long freespace , long classMetadata, long freespaceUsage, long uuidUsage, ISlotMap slots, long commitTimestampUsage) { _fileSize = fileSize; _fileHeader = fileHeader; _idSystem = idSystem; _freespace = freespace; _classMetadata = classMetadata; _freespaceUsage = freespaceUsage; _uuidUsage = uuidUsage; _slots = slots; _commitTimestampUsage = commitTimestampUsage; } /// bytes used by the db4o file header (static and variable parts) public virtual long FileHeader() { return _fileHeader; } /// total number of bytes registered as freespace, available for reuse public virtual long Freespace() { return _freespace; } /// bytes used by the id system indices public virtual long IdSystem() { return _idSystem; } /// number of bytes used for class metadata (class metadata repository and schema definitions) /// public virtual long ClassMetadata() { return _classMetadata; } /// number of bytes used for the bookkeeping of the freespace system itself public virtual long FreespaceUsage() { return _freespaceUsage; } /// number of bytes used for the uuid index public virtual long UuidUsage() { return _uuidUsage; } /// number of bytes used for the commit timestamp indexes public virtual long CommitTimestampUsage() { return _commitTimestampUsage; } /// total file size in bytes public virtual long FileSize() { return _fileSize; } /// /// number of bytes used aggregated from all categories - should always be equal to /// FileSize() /// public virtual long TotalUsage() { LongByRef total = new LongByRef(_fileHeader + _freespace + _idSystem + _classMetadata + _freespaceUsage + _uuidUsage + _commitTimestampUsage); Tree.Traverse(_classUsageStats, new _IVisitor4_98(total)); return total.value; } private sealed class _IVisitor4_98 : IVisitor4 { public _IVisitor4_98(LongByRef total) { this.total = total; } public void Visit(object node) { total.value += ((Db4objects.Db4o.Filestats.ClassUsageStats)((TreeStringObject)node )._value).TotalUsage(); } private readonly LongByRef total; } /// the statistics for each persisted class public virtual IEnumerator ClassUsageStats() { return new TreeNodeIterator(_classUsageStats); } /// a fully qualified class name /// the statistics for the class with the given name public virtual Db4objects.Db4o.Filestats.ClassUsageStats ClassStats(string name) { TreeStringObject found = (TreeStringObject)Tree.Find(_classUsageStats, new TreeStringObject (name, null)); return found == null ? null : ((Db4objects.Db4o.Filestats.ClassUsageStats)found._value ); } public override string ToString() { StringBuilder str = new StringBuilder(); Tree.Traverse(_classUsageStats, new _IVisitor4_124(str)); str.Append("\n"); str.Append(FileUsageStatsUtil.FormatLine("File header", FileHeader())); str.Append(FileUsageStatsUtil.FormatLine("Freespace", Freespace())); str.Append(FileUsageStatsUtil.FormatLine("ID system", IdSystem())); str.Append(FileUsageStatsUtil.FormatLine("Class metadata", ClassMetadata())); str.Append(FileUsageStatsUtil.FormatLine("Freespace usage", FreespaceUsage())); str.Append(FileUsageStatsUtil.FormatLine("UUID usage", UuidUsage())); str.Append(FileUsageStatsUtil.FormatLine("Version usage", CommitTimestampUsage()) ); str.Append("\n"); long totalUsage = TotalUsage(); str.Append(FileUsageStatsUtil.FormatLine("Total", totalUsage)); str.Append(FileUsageStatsUtil.FormatLine("Unaccounted", FileSize() - totalUsage)); str.Append(FileUsageStatsUtil.FormatLine("File", FileSize())); str.Append(_slots); return str.ToString(); } private sealed class _IVisitor4_124 : IVisitor4 { public _IVisitor4_124(StringBuilder str) { this.str = str; } public void Visit(object node) { ((Db4objects.Db4o.Filestats.ClassUsageStats)((TreeStringObject)node)._value).ToString (str); } private readonly StringBuilder str; } internal virtual void AddClassStats(Db4objects.Db4o.Filestats.ClassUsageStats classStats ) { _classUsageStats = ((TreeStringObject)Tree.Add(_classUsageStats, new TreeStringObject (classStats.ClassName(), classStats))); } internal virtual void AddSlot(Slot slot) { _slots.Add(slot); } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Tools/000755 001750 001750 00000000000 11520622042 027120 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Tools/Statistics.cs000644 001750 001750 00000014474 11520622624 031621 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Tools; namespace Db4objects.Db4o.Tools { /// prints statistics about a database file to System.out. /// /// prints statistics about a database file to System.out. ///

Pass the database file path as an argument. ///

This class is not part of db4o.jar!
/// It is delivered as sourcecode in the /// path ../com/db4o/tools/

///
public class Statistics { /// the main method that runs the statistics. /// the main method that runs the statistics. /// /// a String array of length 1, with the name of the database /// file as element 0. /// public static void Main(string[] args) { if (args == null || args.Length != 1) { Sharpen.Runtime.Out.WriteLine("Usage: java com.db4o.tools.Statistics " ); } else { new Statistics().Run(args[0]); } } public virtual void Run(string filename) { if (new Sharpen.IO.File(filename).Exists()) { IObjectContainer con = null; try { IConfiguration config = Db4oFactory.NewConfiguration(); config.MessageLevel(-1); con = Db4oFactory.OpenFile(config, filename); PrintHeader("STATISTICS"); Sharpen.Runtime.Out.WriteLine("File: " + filename); PrintStats(con, filename); con.Close(); } catch (Exception e) { Sharpen.Runtime.Out.WriteLine("Statistics failed for file: '" + filename + "'"); Sharpen.Runtime.Out.WriteLine(e.Message); Sharpen.Runtime.PrintStackTrace(e); } } else { Sharpen.Runtime.Out.WriteLine("File not found: '" + filename + "'"); } } private static bool CanCallConstructor(string className) { return ReflectPlatform.CreateInstance(className) != null; } private void PrintStats(IObjectContainer con, string filename) { Tree unavailable = new TreeString(Remove); Tree noConstructor = new TreeString(Remove); // one element too many, substract one in the end IStoredClass[] internalClasses = con.Ext().StoredClasses(); for (int i = 0; i < internalClasses.Length; i++) { string internalClassName = internalClasses[i].GetName(); Type clazz = ReflectPlatform.ForName(internalClassName); if (clazz == null) { unavailable = unavailable.Add(new TreeString(internalClassName)); } else { if (!CanCallConstructor(internalClassName)) { noConstructor = noConstructor.Add(new TreeString(internalClassName)); } } } unavailable = unavailable.RemoveLike(new TreeString(Remove)); noConstructor = noConstructor.RemoveLike(new TreeString(Remove)); if (unavailable != null) { PrintHeader("UNAVAILABLE"); unavailable.Traverse(new _IVisitor4_80()); } if (noConstructor != null) { PrintHeader("NO PUBLIC CONSTRUCTOR"); noConstructor.Traverse(new _IVisitor4_88()); } PrintHeader("CLASSES"); Sharpen.Runtime.Out.WriteLine("Number of objects per class:"); ByRef ids = ByRef.NewInstance(new TreeInt(0)); if (internalClasses.Length > 0) { Tree all = new TreeStringObject(internalClasses[0].GetName(), internalClasses[0]); for (int i = 1; i < internalClasses.Length; i++) { all = all.Add(new TreeStringObject(internalClasses[i].GetName(), internalClasses[ i])); } all.Traverse(new _IVisitor4_107(ids)); } PrintHeader("SUMMARY"); Sharpen.Runtime.Out.WriteLine("File: " + filename); Sharpen.Runtime.Out.WriteLine("Stored classes: " + internalClasses.Length); if (unavailable != null) { Sharpen.Runtime.Out.WriteLine("Unavailable classes: " + unavailable.Size()); } if (noConstructor != null) { Sharpen.Runtime.Out.WriteLine("Classes without public constructors: " + noConstructor .Size()); } Sharpen.Runtime.Out.WriteLine("Total number of objects: " + (((Tree)ids.value).Size () - 1)); } private sealed class _IVisitor4_80 : IVisitor4 { public _IVisitor4_80() { } public void Visit(object obj) { Sharpen.Runtime.Out.WriteLine(((TreeString)obj)._key); } } private sealed class _IVisitor4_88 : IVisitor4 { public _IVisitor4_88() { } public void Visit(object obj) { Sharpen.Runtime.Out.WriteLine(((TreeString)obj)._key); } } private sealed class _IVisitor4_107 : IVisitor4 { public _IVisitor4_107(ByRef ids) { this.ids = ids; } public void Visit(object obj) { TreeStringObject node = (TreeStringObject)obj; long[] newIDs = ((IStoredClass)node._value).GetIDs(); for (int j = 0; j < newIDs.Length; j++) { if (((Tree)ids.value).Find(new TreeInt((int)newIDs[j])) == null) { ids.value = ((TreeInt)((Tree)ids.value).Add(new TreeInt((int)newIDs[j]))); } } Sharpen.Runtime.Out.WriteLine(node._key + ": " + newIDs.Length); } private readonly ByRef ids; } private void PrintHeader(string str) { int stars = (39 - str.Length) / 2; Sharpen.Runtime.Out.WriteLine("\n"); for (int i = 0; i < stars; i++) { Sharpen.Runtime.Out.Write("*"); } Sharpen.Runtime.Out.Write(" " + str + " "); for (int i = 0; i < stars; i++) { Sharpen.Runtime.Out.Write("*"); } Sharpen.Runtime.Out.WriteLine(); } private static readonly string Remove = "XXxxREMOVExxXX"; } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Foundation/000755 001750 001750 00000000000 11520622064 030132 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Foundation/TreeStringObject.cs000644 001750 001750 00000002213 11520622624 033676 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Foundation; namespace Db4objects.Db4o.Foundation { public class TreeStringObject : TreeString { public readonly object _value; public TreeStringObject(string key, object value) : base(key) { this._value = value; } public override object ShallowClone() { Db4objects.Db4o.Foundation.TreeStringObject tso = new Db4objects.Db4o.Foundation.TreeStringObject (_key, _value); return ShallowCloneInternal(tso); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Foundation/TreeString.cs000644 001750 001750 00000003062 11520622624 032552 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Handlers; namespace Db4objects.Db4o.Foundation { public class TreeString : Tree { public string _key; public TreeString(string key) { this._key = key; } protected override Tree ShallowCloneInternal(Tree tree) { Db4objects.Db4o.Foundation.TreeString ts = (Db4objects.Db4o.Foundation.TreeString )base.ShallowCloneInternal(tree); ts._key = _key; return ts; } public override object ShallowClone() { return ShallowCloneInternal(new Db4objects.Db4o.Foundation.TreeString(_key)); } public override int Compare(Tree to) { return StringHandler.Compare(Const4.stringIO.Write(_key), Const4.stringIO.Write(( (Db4objects.Db4o.Foundation.TreeString)to)._key)); } public override object Key() { return _key; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Consistency/000755 001750 001750 00000000000 11520622040 030317 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/Db4objects.Db4o/Consistency/ConsistencyChecker.cs000644 001750 001750 00000026433 11520622624 034375 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using System.Text; using Db4objects.Db4o; using Db4objects.Db4o.Consistency; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Btree; using Db4objects.Db4o.Internal.Classindex; using Db4objects.Db4o.Internal.Ids; using Db4objects.Db4o.Internal.Slots; namespace Db4objects.Db4o.Consistency { public class ConsistencyChecker { private readonly LocalObjectContainer _db; private readonly IList bogusSlots = new ArrayList(); private TreeIntObject mappings; public class SlotSource { public static readonly ConsistencyChecker.SlotSource IdSystem = new ConsistencyChecker.SlotSource ("IdSystem"); public static readonly ConsistencyChecker.SlotSource Freespace = new ConsistencyChecker.SlotSource ("Freespace"); private readonly string _name; private SlotSource(string name) { _name = name; } public override string ToString() { return _name; } } public class SlotWithSource { public readonly Slot slot; public readonly ConsistencyChecker.SlotSource source; public SlotWithSource(Slot slot, ConsistencyChecker.SlotSource source) { this.slot = slot; this.source = source; } public override string ToString() { return slot + "(" + source + ")"; } } public class ConsistencyReport { private const int MaxReportedItems = 50; internal readonly IList bogusSlots; internal readonly IList overlaps; internal readonly IList invalidObjectIds; internal readonly IList invalidFieldIndexEntries; public ConsistencyReport(IList bogusSlots, IList overlaps, IList invalidClassIds, IList invalidFieldIndexEntries) { this.bogusSlots = bogusSlots; this.overlaps = overlaps; this.invalidObjectIds = invalidClassIds; this.invalidFieldIndexEntries = invalidFieldIndexEntries; } public virtual bool Consistent() { return bogusSlots.Count == 0 && overlaps.Count == 0 && invalidObjectIds.Count == 0 && invalidFieldIndexEntries.Count == 0; } public override string ToString() { if (Consistent()) { return "no inconsistencies detected"; } StringBuilder message = new StringBuilder("INCONSISTENCIES DETECTED\n").Append(overlaps .Count + " overlaps\n").Append(bogusSlots.Count + " bogus slots\n").Append(invalidObjectIds .Count + " invalid class ids\n").Append(invalidFieldIndexEntries.Count + " invalid field index entries\n" ); message.Append("(slot lengths are non-blocked)\n"); AppendInconsistencyReport(message, "OVERLAPS", overlaps); AppendInconsistencyReport(message, "BOGUS SLOTS", bogusSlots); AppendInconsistencyReport(message, "INVALID OBJECT IDS", invalidObjectIds); AppendInconsistencyReport(message, "INVALID FIELD INDEX ENTRIES", invalidFieldIndexEntries ); return message.ToString(); } private void AppendInconsistencyReport(StringBuilder str, string title, IList entries ) { if (entries.Count != 0) { str.Append(title + "\n"); int count = 0; for (IEnumerator entryIter = entries.GetEnumerator(); entryIter.MoveNext(); ) { object entry = entryIter.Current; str.Append(entry).Append("\n"); count++; if (count > MaxReportedItems) { str.Append("and more...\n"); break; } } } } } public static void Main(string[] args) { IEmbeddedObjectContainer db = Db4oEmbedded.OpenFile(args[0]); try { Sharpen.Runtime.Out.WriteLine(new ConsistencyChecker(db).CheckSlotConsistency()); } finally { db.Close(); } } public ConsistencyChecker(IObjectContainer db) { _db = (LocalObjectContainer)db; } public virtual ConsistencyChecker.ConsistencyReport CheckSlotConsistency() { MapIdSystem(); MapFreespace(); return new ConsistencyChecker.ConsistencyReport(bogusSlots, CollectOverlaps(), CheckClassIndices (), CheckFieldIndices()); } private IList CheckClassIndices() { IList invalidIds = new ArrayList(); IIdSystem idSystem = _db.IdSystem(); if (!(idSystem is BTreeIdSystem)) { return invalidIds; } ClassMetadataIterator clazzIter = _db.ClassCollection().Iterator(); while (clazzIter.MoveNext()) { ClassMetadata clazz = clazzIter.CurrentClass(); if (!clazz.HasClassIndex()) { continue; } BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index(); index.TraverseAll(_db.SystemTransaction(), new _IVisitor4_143(this, invalidIds, clazz )); } return invalidIds; } private sealed class _IVisitor4_143 : IVisitor4 { public _IVisitor4_143(ConsistencyChecker _enclosing, IList invalidIds, ClassMetadata clazz) { this._enclosing = _enclosing; this.invalidIds = invalidIds; this.clazz = clazz; } public void Visit(object id) { if (!this._enclosing.IdIsValid((((int)id)))) { invalidIds.Add(new Pair(clazz.GetName(), ((int)id))); } } private readonly ConsistencyChecker _enclosing; private readonly IList invalidIds; private readonly ClassMetadata clazz; } private IList CheckFieldIndices() { IList invalidIds = new ArrayList(); ClassMetadataIterator clazzIter = _db.ClassCollection().Iterator(); while (clazzIter.MoveNext()) { ClassMetadata clazz = clazzIter.CurrentClass(); clazz.TraverseDeclaredFields(new _IProcedure4_159(this, invalidIds, clazz)); } return invalidIds; } private sealed class _IProcedure4_159 : IProcedure4 { public _IProcedure4_159(ConsistencyChecker _enclosing, IList invalidIds, ClassMetadata clazz) { this._enclosing = _enclosing; this.invalidIds = invalidIds; this.clazz = clazz; } public void Apply(object field) { if (!((FieldMetadata)field).HasIndex()) { return; } BTree fieldIndex = ((FieldMetadata)field).GetIndex(this._enclosing._db.SystemTransaction ()); fieldIndex.TraverseKeys(this._enclosing._db.SystemTransaction(), new _IVisitor4_165 (this, invalidIds, clazz, field)); } private sealed class _IVisitor4_165 : IVisitor4 { public _IVisitor4_165(_IProcedure4_159 _enclosing, IList invalidIds, ClassMetadata clazz, object field) { this._enclosing = _enclosing; this.invalidIds = invalidIds; this.clazz = clazz; this.field = field; } public void Visit(object fieldIndexKey) { int parentID = ((IFieldIndexKey)fieldIndexKey).ParentID(); if (!this._enclosing._enclosing.IdIsValid(parentID)) { invalidIds.Add(new Pair(clazz.GetName() + "#" + ((FieldMetadata)field).GetName(), parentID)); } } private readonly _IProcedure4_159 _enclosing; private readonly IList invalidIds; private readonly ClassMetadata clazz; private readonly object field; } private readonly ConsistencyChecker _enclosing; private readonly IList invalidIds; private readonly ClassMetadata clazz; } private bool IdIsValid(int id) { try { return !Slot.IsNull(_db.IdSystem().CommittedSlot(id)); } catch (InvalidIDException) { return false; } } private IList CollectOverlaps() { IBlockConverter blockConverter = _db.BlockConverter(); IList overlaps = new ArrayList(); ByRef prevSlot = ByRef.NewInstance(); mappings.Traverse(new _IVisitor4_192(prevSlot, blockConverter, overlaps)); return overlaps; } private sealed class _IVisitor4_192 : IVisitor4 { public _IVisitor4_192(ByRef prevSlot, IBlockConverter blockConverter, IList overlaps ) { this.prevSlot = prevSlot; this.blockConverter = blockConverter; this.overlaps = overlaps; } public void Visit(object obj) { ConsistencyChecker.SlotWithSource curSlot = (ConsistencyChecker.SlotWithSource)(( TreeIntObject)obj)._object; if (((ConsistencyChecker.SlotWithSource)prevSlot.value) != null) { if (((ConsistencyChecker.SlotWithSource)prevSlot.value).slot.Address() + blockConverter .ToBlockedLength(((ConsistencyChecker.SlotWithSource)prevSlot.value).slot).Length () > curSlot.slot.Address()) { overlaps.Add(new Pair(((ConsistencyChecker.SlotWithSource)prevSlot.value), curSlot )); } } prevSlot.value = curSlot; } private readonly ByRef prevSlot; private readonly IBlockConverter blockConverter; private readonly IList overlaps; } private void MapFreespace() { _db.FreespaceManager().Traverse(new _IVisitor4_207(this)); } private sealed class _IVisitor4_207 : IVisitor4 { public _IVisitor4_207(ConsistencyChecker _enclosing) { this._enclosing = _enclosing; } public void Visit(object slot) { if (((Slot)slot).Address() < 0) { this._enclosing.bogusSlots.Add(new ConsistencyChecker.SlotWithSource(((Slot)slot) , ConsistencyChecker.SlotSource.Freespace)); } this._enclosing.AddMapping(((Slot)slot), ConsistencyChecker.SlotSource.Freespace); } private readonly ConsistencyChecker _enclosing; } private void MapIdSystem() { IIdSystem idSystem = _db.IdSystem(); if (idSystem is BTreeIdSystem) { ((BTreeIdSystem)idSystem).TraverseIds(new _IVisitor4_220(this)); } } private sealed class _IVisitor4_220 : IVisitor4 { public _IVisitor4_220(ConsistencyChecker _enclosing) { this._enclosing = _enclosing; } public void Visit(object mapping) { if (((IdSlotMapping)mapping)._address < 0) { this._enclosing.bogusSlots.Add(new ConsistencyChecker.SlotWithSource(((IdSlotMapping )mapping).Slot(), ConsistencyChecker.SlotSource.IdSystem)); } if (((IdSlotMapping)mapping)._address > 0) { this._enclosing.AddMapping(((IdSlotMapping)mapping).Slot(), ConsistencyChecker.SlotSource .IdSystem); } } private readonly ConsistencyChecker _enclosing; } private void AddMapping(Slot slot, ConsistencyChecker.SlotSource source) { mappings = ((TreeIntObject)Tree.Add(mappings, new ConsistencyChecker.MappingTree( slot, source))); } private class MappingTree : TreeIntObject { public MappingTree(Slot slot, ConsistencyChecker.SlotSource source) : base(slot.Address (), new ConsistencyChecker.SlotWithSource(slot, source)) { } public override bool Duplicates() { return true; } } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/IO/000755 001750 001750 00000000000 11520622070 026330 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/IO/MemoryIoAdapter.cs000644 001750 001750 00000017363 11520622624 031737 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Foundation; using Db4objects.Db4o.IO; using Sharpen; namespace Db4objects.Db4o.IO { /// IoAdapter for in-memory operation. /// /// IoAdapter for in-memory operation.
///
/// Configure db4o to operate with this in-memory IoAdapter with /// /// MemoryIoAdapter memoryIoAdapter = new MemoryIoAdapter();
/// Db4oFactory.Configure().Io(memoryIoAdapter); ///

///
///
/// Use the normal #openFile() and #openServer() commands to open /// ObjectContainers and ObjectServers. The names specified as file names will be /// used to identify the byte[] content of the in-memory files in /// the _memoryFiles Hashtable in the adapter. After working with an in-memory /// ObjectContainer/ObjectServer the byte[] content is available /// in the MemoryIoAdapter by using /// /// Db4objects.Db4o.IO.MemoryIoAdapter.Get /// /// . To add old existing /// database byte[] content to a MemoryIoAdapter use /// /// Db4objects.Db4o.IO.MemoryIoAdapter.Put /// /// /// . To reduce memory consumption of memory file /// names that will no longer be used call /// /// Db4objects.Db4o.IO.MemoryIoAdapter.Put /// /// /// and pass /// an empty byte array. /// ///
public class MemoryIoAdapter : IoAdapter { private byte[] _bytes; private int _length; private int _seekPos; private Hashtable4 _memoryFiles; private int _growBy; public MemoryIoAdapter() { _memoryFiles = new Hashtable4(); _growBy = 10000; } public MemoryIoAdapter(int initialLength) : this() { _bytes = new byte[initialLength]; } private MemoryIoAdapter(Db4objects.Db4o.IO.MemoryIoAdapter adapter, byte[] bytes) { _bytes = bytes; _length = bytes.Length; _growBy = adapter._growBy; } private MemoryIoAdapter(Db4objects.Db4o.IO.MemoryIoAdapter adapter, int initialLength ) : this(adapter, new byte[initialLength]) { } /// /// creates an in-memory database with the passed content bytes and adds it /// to the adapter for the specified name. /// /// /// creates an in-memory database with the passed content bytes and adds it /// to the adapter for the specified name. /// /// the name to be use for #openFile() or #openServer() calls /// the database content public virtual void Put(string name, byte[] bytes) { if (bytes == null) { bytes = new byte[0]; } _memoryFiles.Put(name, new Db4objects.Db4o.IO.MemoryIoAdapter(this, bytes)); } /// returns the content bytes for a database with the given name. /// returns the content bytes for a database with the given name. /// the name to be use for #openFile() or #openServer() calls /// the content bytes public virtual byte[] Get(string name) { Db4objects.Db4o.IO.MemoryIoAdapter mia = (Db4objects.Db4o.IO.MemoryIoAdapter)_memoryFiles .Get(name); if (mia == null) { return null; } return mia._bytes; } /// /// configures the length a memory file should grow, if no more free slots /// are found within. /// /// /// configures the length a memory file should grow, if no more free slots /// are found within.
///
/// Specify a large value (100,000 or more) for best performance. Specify a /// small value (100) for the smallest memory consumption. The default /// setting is 10,000. ///
/// the length in bytes public virtual void GrowBy(int length) { if (length < 1) { length = 1; } _growBy = length; } /// for internal processing only. /// for internal processing only. /// public override void Close() { } // do nothing public override void Delete(string path) { _memoryFiles.Remove(path); } /// for internal processing only. /// for internal processing only. public override bool Exists(string path) { Db4objects.Db4o.IO.MemoryIoAdapter mia = (Db4objects.Db4o.IO.MemoryIoAdapter)_memoryFiles .Get(path); if (mia == null) { return false; } return mia._length > 0; } /// for internal processing only. /// for internal processing only. /// public override long GetLength() { return _length; } /// for internal processing only. /// for internal processing only. /// public override IoAdapter Open(string path, bool lockFile, long initialLength, bool readOnly) { Db4objects.Db4o.IO.MemoryIoAdapter mia = (Db4objects.Db4o.IO.MemoryIoAdapter)_memoryFiles .Get(path); if (mia == null) { mia = new Db4objects.Db4o.IO.MemoryIoAdapter(this, (int)initialLength); _memoryFiles.Put(path, mia); } return mia; } /// for internal processing only. /// for internal processing only. /// public override int Read(byte[] bytes, int length) { System.Array.Copy(_bytes, _seekPos, bytes, 0, length); _seekPos += length; return length; } /// for internal processing only. /// for internal processing only. /// public override void Seek(long pos) { _seekPos = (int)pos; } /// for internal processing only. /// for internal processing only. /// public override void Sync() { } /// for internal processing only. /// for internal processing only. /// public override void Write(byte[] buffer, int length) { if (_seekPos + length > _bytes.Length) { int growBy = _growBy; int missing = _seekPos + length - _bytes.Length; if (missing > growBy) { growBy = missing; } byte[] temp = new byte[_bytes.Length + growBy]; System.Array.Copy(_bytes, 0, temp, 0, _length); _bytes = temp; } System.Array.Copy(buffer, 0, _bytes, _seekPos, length); _seekPos += length; if (_seekPos > _length) { _length = _seekPos; } } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/IO/SaveAsStorage.cs000644 001750 001750 00000016234 11520622624 031401 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Foundation.IO; using Db4objects.Db4o.IO; using Sharpen.Lang; namespace Db4objects.Db4o.IO { /// /// Storage that allows to save an open database file /// as another file while keeping the reference system /// in place. /// /// /// Storage that allows to save an open database file /// as another file while keeping the reference system /// in place. If anything goes wrong during copying the /// storage tries to reopen the original file, so commit /// operations can still take place against the original /// file. /// public class SaveAsStorage : StorageDecorator { private readonly Hashtable4 _binRecords = new Hashtable4(); public SaveAsStorage(IStorage storage) : base(storage) { } /// /// call this method to save the content of a currently /// open ObjectContainer session to a new file location. /// /// /// call this method to save the content of a currently /// open ObjectContainer session to a new file location. /// Invocation will close the old file without a commit, /// keep the reference system in place and connect it to /// the file in the new location. If anything goes wrong /// during the copying operation or while opening it will /// be attempted to reopen the old file. In this case a /// Db4oException will be thrown. /// /// the path to the old open database file /// the path to the new database file public virtual void SaveAs(string oldUri, string newUri) { if (System.IO.File.Exists(newUri)) { throw new InvalidOperationException(newUri + " already exists"); } SaveAsStorage.BinRecord binRecord = (SaveAsStorage.BinRecord)_binRecords.Get(oldUri ); if (binRecord == null) { throw new InvalidOperationException(oldUri + " was never opened or was closed."); } BinConfiguration oldConfiguration = binRecord._binConfiguration; SaveAsStorage.SaveAsBin saveAsBin = binRecord._bin; IRunnable closure = new _IRunnable_49(this, saveAsBin, oldUri, newUri, oldConfiguration ); saveAsBin.ExchangeUnderlyingBin(closure); } private sealed class _IRunnable_49 : IRunnable { public _IRunnable_49(SaveAsStorage _enclosing, SaveAsStorage.SaveAsBin saveAsBin, string oldUri, string newUri, BinConfiguration oldConfiguration) { this._enclosing = _enclosing; this.saveAsBin = saveAsBin; this.oldUri = oldUri; this.newUri = newUri; this.oldConfiguration = oldConfiguration; } public void Run() { saveAsBin.Sync(); saveAsBin.Close(); try { File4.Copy(oldUri, newUri); } catch (Exception e) { this._enclosing.ReopenOldConfiguration(saveAsBin, oldConfiguration, newUri, e); } BinConfiguration newConfiguration = this._enclosing.PointToNewUri(oldConfiguration , newUri); try { IBin newBin = this._enclosing._storage.Open(newConfiguration); saveAsBin.DelegateTo(newBin); this._enclosing._binRecords.Remove(oldUri); this._enclosing._binRecords.Put(newUri, new SaveAsStorage.BinRecord(newConfiguration , saveAsBin)); } catch (Exception e) { this._enclosing.ReopenOldConfiguration(saveAsBin, oldConfiguration, newUri, e); } } private readonly SaveAsStorage _enclosing; private readonly SaveAsStorage.SaveAsBin saveAsBin; private readonly string oldUri; private readonly string newUri; private readonly BinConfiguration oldConfiguration; } private BinConfiguration PointToNewUri(BinConfiguration oldConfig, string newUri) { return new BinConfiguration(newUri, oldConfig.LockFile(), oldConfig.InitialLength (), oldConfig.ReadOnly()); } private void ReopenOldConfiguration(SaveAsStorage.SaveAsBin saveAsBin, BinConfiguration config, string newUri, Exception e) { IBin safeBin = _storage.Open(config); saveAsBin.DelegateTo(safeBin); throw new Db4oException("Copying to " + newUri + " failed. Reopened " + config.Uri (), e); } /// public override IBin Open(BinConfiguration config) { SaveAsStorage.SaveAsBin openedBin = new SaveAsStorage.SaveAsBin(base.Open(config) ); _binRecords.Put(config.Uri(), new SaveAsStorage.BinRecord(config, openedBin)); return openedBin; } private class BinRecord { internal readonly SaveAsStorage.SaveAsBin _bin; internal readonly BinConfiguration _binConfiguration; internal BinRecord(BinConfiguration binConfiguration, SaveAsStorage.SaveAsBin bin ) { _binConfiguration = binConfiguration; _bin = bin; } } /// /// We could have nicely used BinDecorator here, but /// BinDecorator doesn't allow exchanging the Bin. /// /// /// We could have nicely used BinDecorator here, but /// BinDecorator doesn't allow exchanging the Bin. To /// be compatible with released versions we do /// private class SaveAsBin : IBin { private IBin _bin; internal SaveAsBin(IBin delegate_) { _bin = delegate_; } public virtual void ExchangeUnderlyingBin(IRunnable closure) { lock (this) { closure.Run(); } } public virtual void Close() { lock (this) { _bin.Close(); } } public virtual long Length() { lock (this) { return _bin.Length(); } } public virtual int Read(long position, byte[] bytes, int bytesToRead) { lock (this) { return _bin.Read(position, bytes, bytesToRead); } } public virtual void Sync() { lock (this) { _bin.Sync(); } } public virtual void Sync(IRunnable runnable) { lock (this) { Sync(); runnable.Run(); Sync(); } } public virtual int SyncRead(long position, byte[] bytes, int bytesToRead) { lock (this) { return _bin.SyncRead(position, bytes, bytesToRead); } } public virtual void Write(long position, byte[] bytes, int bytesToWrite) { lock (this) { _bin.Write(position, bytes, bytesToWrite); } } public virtual void DelegateTo(IBin bin) { _bin = bin; } } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/IO/DebugIoAdapter.cs000644 001750 001750 00000003620 11520622624 031504 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.IO; namespace Db4objects.Db4o.IO { /// public class DebugIoAdapter : VanillaIoAdapter { internal static int counter; private static readonly int[] RangeOfInterest = new int[] { 0, 20 }; public DebugIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter) { } /// protected DebugIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long initialLength, bool readOnly) : base(delegateAdapter.Open(path, lockFile, initialLength , readOnly)) { } /// public override IoAdapter Open(string path, bool lockFile, long initialLength, bool readOnly) { return new Db4objects.Db4o.IO.DebugIoAdapter(new RandomAccessFileAdapter(), path, lockFile, initialLength, readOnly); } /// public override void Seek(long pos) { if (pos >= RangeOfInterest[0] && pos <= RangeOfInterest[1]) { counter++; Sharpen.Runtime.Out.WriteLine("seek: " + pos + " counter: " + counter); } base.Seek(pos); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/IO/NonFlushingIoAdapter.cs000644 001750 001750 00000010251 11520622624 032706 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.IO; namespace Db4objects.Db4o.IO { /// /// Delegating IoAdapter that does not pass on calls to sync /// data to the underlying device. /// /// /// Delegating IoAdapter that does not pass on calls to sync /// data to the underlying device.

/// This IoAdapter can be used to improve performance at the cost of a /// higher risk of database file corruption upon abnormal termination /// of a session against a database.

/// An example of possible usage:
/// /// RandomAccessFileAdapter randomAccessFileAdapter = new RandomAccessFileAdapter();
/// NonFlushingIoAdapter nonFlushingIoAdapter = new NonFlushingIoAdapter(randomAccessFileAdapter);
/// CachedIoAdapter cachedIoAdapter = new CachedIoAdapter(nonFlushingIoAdapter);
/// Configuration configuration = Db4o.newConfiguration();
/// configuration.io(cachedIoAdapter);
///
///

/// db4o uses a resume-commit-on-crash strategy to ensure ACID transactions. /// When a transaction commits,
/// - (1) a list "pointers that are to be modified" is written to the database file,
/// - (2) the database file is switched into "in-commit" mode,
/// - (3) the pointers are actually modified in the database file,
/// - (4) the database file is switched to "not-in-commit" mode.
/// If the system is halted by a hardware or power failure
/// - before (2)
/// all objects will be available as before the commit
/// - between (2) and (4) /// the commit is restarted when the database file is opened the next time, all pointers /// will be read from the "pointers to be modified" list and all of them will be modified /// to the state they are intended to have after commit
/// - after (4) /// no work is necessary, the transaction is committed. ///

/// In order for the above to be 100% failsafe, the order of writes to the /// storage medium has to be obeyed. On operating systems that use in-memory /// file caching, the OS cache may revert the order of writes to optimize /// file performance.

/// db4o enforces the correct write order by calling /// Sync() /// after every single one of the above steps during transaction /// commit. The calls to /// Sync() /// have a high performance cost. /// By using this IoAdapter it is possible to omit these calls, at the cost /// of a risc of corrupted database files upon hardware-, power- or operating /// system failures.

///
public class NonFlushingIoAdapter : VanillaIoAdapter { public NonFlushingIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter) { } /// private NonFlushingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile , long initialLength, bool readOnly) : base(delegateAdapter, path, lockFile, initialLength , readOnly) { } /// public override IoAdapter Open(string path, bool lockFile, long initialLength, bool readOnly) { return new Db4objects.Db4o.IO.NonFlushingIoAdapter(_delegate, path, lockFile, initialLength , readOnly); } /// public override void Sync() { } // do nothing } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Cluster/000755 001750 001750 00000000000 11520622044 027443 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Cluster/Cluster.cs000644 001750 001750 00000005414 11520622624 031423 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o; using Db4objects.Db4o.Internal.Cluster; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Cluster { /// allows running Queries against multiple ObjectContainers. /// allows running Queries against multiple ObjectContainers. /// public class Cluster { public readonly IObjectContainer[] _objectContainers; /// /// use this constructor to create a Cluster and call /// add() to add ObjectContainers /// public Cluster(IObjectContainer[] objectContainers) { if (objectContainers == null) { throw new ArgumentNullException(); } if (objectContainers.Length < 1) { throw new ArgumentException(); } for (int i = 0; i < objectContainers.Length; i++) { if (objectContainers[i] == null) { throw new ArgumentException(); } } _objectContainers = objectContainers; } /// /// starts a query against all ObjectContainers in /// this Cluster. /// /// /// starts a query against all ObjectContainers in /// this Cluster. /// /// the Query public virtual IQuery Query() { lock (this) { IQuery[] queries = new IQuery[_objectContainers.Length]; for (int i = 0; i < _objectContainers.Length; i++) { queries[i] = _objectContainers[i].Query(); } return new ClusterQuery(this, queries); } } /// /// returns the ObjectContainer in this cluster where the passed object /// is stored or null, if the object is not stored to any ObjectContainer /// in this cluster /// /// the object /// the ObjectContainer public virtual IObjectContainer ObjectContainerFor(object obj) { lock (this) { for (int i = 0; i < _objectContainers.Length; i++) { if (_objectContainers[i].Ext().IsStored(obj)) { return _objectContainers[i]; } } } return null; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Internal/000755 001750 001750 00000000000 11520622050 027573 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Internal/Cluster/000755 001750 001750 00000000000 11520622066 031223 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Optional/Db4objects.Db4o/Internal/Cluster/ClusterConstraint.cs000644 001750 001750 00000010632 11520622624 035163 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Internal.Cluster { /// public class ClusterConstraint : IConstraint { internal readonly Db4objects.Db4o.Cluster.Cluster _cluster; internal readonly IConstraint[] _constraints; public ClusterConstraint(Db4objects.Db4o.Cluster.Cluster cluster, IConstraint[] constraints ) { _cluster = cluster; _constraints = constraints; } private Db4objects.Db4o.Internal.Cluster.ClusterConstraint Compatible(IConstraint with) { if (!(with is Db4objects.Db4o.Internal.Cluster.ClusterConstraint)) { throw new ArgumentException(); } Db4objects.Db4o.Internal.Cluster.ClusterConstraint other = (Db4objects.Db4o.Internal.Cluster.ClusterConstraint )with; if (other._constraints.Length != _constraints.Length) { throw new ArgumentException(); } return other; } public virtual IConstraint And(IConstraint with) { return Join(with, true); } public virtual IConstraint Or(IConstraint with) { return Join(with, false); } private IConstraint Join(IConstraint with, bool isAnd) { lock (_cluster) { Db4objects.Db4o.Internal.Cluster.ClusterConstraint other = Compatible(with); IConstraint[] newConstraints = new IConstraint[_constraints.Length]; for (int i = 0; i < _constraints.Length; i++) { newConstraints[i] = isAnd ? _constraints[i].And(other._constraints[i]) : _constraints [i].Or(other._constraints[i]); } return new Db4objects.Db4o.Internal.Cluster.ClusterConstraint(_cluster, newConstraints ); } } public virtual IConstraint Equal() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Equal(); } return this; } } public virtual IConstraint Greater() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Greater(); } return this; } } public virtual IConstraint Smaller() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Smaller(); } return this; } } public virtual IConstraint Identity() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Identity(); } return this; } } public virtual IConstraint ByExample() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].ByExample(); } return this; } } public virtual IConstraint Like() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Like(); } return this; } } public virtual IConstraint StartsWith(bool caseSensitive) { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].StartsWith(caseSensitive); } return this; } } public virtual IConstraint EndsWith(bool caseSensitive) { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].EndsWith(caseSensitive); } return this; } } public virtual IConstraint Contains() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Contains(); } return this; } } public virtual IConstraint Not() { lock (_cluster) { for (int i = 0; i < _constraints.Length; i++) { _constraints[i].Not(); } return this; } } public virtual object GetObject() { throw new NotSupportedException(); } } } src/Db4objects.Db4o.Optional/Db4objects.Db4o/Internal/Cluster/ClusterQueryResult.cs000644 001750 001750 00000010672 11520622624 035347 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Cluster; using Db4objects.Db4o.Internal.Query; using Db4objects.Db4o.Internal.Query.Processor; using Db4objects.Db4o.Internal.Query.Result; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Internal.Cluster { /// public class ClusterQueryResult : IQueryResult { private readonly Db4objects.Db4o.Cluster.Cluster _cluster; private readonly IObjectSet[] _objectSets; private readonly int[] _sizes; private readonly int _size; public ClusterQueryResult(Db4objects.Db4o.Cluster.Cluster cluster, IQuery[] queries ) { _cluster = cluster; _objectSets = new IObjectSet[queries.Length]; _sizes = new int[queries.Length]; int size = 0; for (int i = 0; i < queries.Length; i++) { _objectSets[i] = queries[i].Execute(); _sizes[i] = _objectSets[i].Count; size += _sizes[i]; } _size = size; } private sealed class ClusterQueryResultIntIterator : IIntIterator4 { private readonly CompositeIterator4 _delegate; public ClusterQueryResultIntIterator(IEnumerator[] iterators) { _delegate = new CompositeIterator4(iterators); } public bool MoveNext() { return _delegate.MoveNext(); } public object Current { get { return _delegate.Current; } } public void Reset() { _delegate.Reset(); } public int CurrentInt() { return ((IIntIterator4)_delegate.CurrentIterator()).CurrentInt(); } } public virtual IIntIterator4 IterateIDs() { lock (_cluster) { IEnumerator[] iterators = new IEnumerator[_objectSets.Length]; for (int i = 0; i < _objectSets.Length; i++) { iterators[i] = ((ObjectSetFacade)_objectSets[i])._delegate.IterateIDs(); } return new ClusterQueryResult.ClusterQueryResultIntIterator(iterators); } } public virtual IEnumerator GetEnumerator() { lock (_cluster) { IEnumerator[] iterators = new IEnumerator[_objectSets.Length]; for (int i = 0; i < _objectSets.Length; i++) { iterators[i] = ((ObjectSetFacade)_objectSets[i])._delegate.GetEnumerator(); } return new CompositeIterator4(iterators); } } public virtual int Size() { return _size; } public virtual object Get(int index) { lock (_cluster) { if (index < 0 || index >= Size()) { throw new IndexOutOfRangeException(); } int i = 0; while (index >= _sizes[i]) { index -= _sizes[i]; i++; } return ((ObjectSetFacade)_objectSets[i])[index]; } } public virtual object Lock() { return _cluster; } public virtual IExtObjectContainer ObjectContainer() { throw new NotSupportedException(); } public virtual int IndexOf(int id) { throw new NotSupportedException(); } public virtual void Sort(IQueryComparator cmp) { throw new NotSupportedException(); } public virtual void SortIds(IIntComparator cmp) { throw new NotSupportedException(); } /// public virtual void LoadFromClassIndex(ClassMetadata c) { throw new NotSupportedException(); } /// public virtual void LoadFromQuery(QQuery q) { throw new NotSupportedException(); } /// public virtual void LoadFromClassIndexes(ClassMetadataIterator i) { throw new NotSupportedException(); } /// public virtual void LoadFromIdReader(ByteArrayBuffer r) { throw new NotSupportedException(); } } } src/Db4objects.Db4o.Optional/Db4objects.Db4o/Internal/Cluster/ClusterQuery.cs000644 001750 001750 00000005214 11520622624 034144 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o; using Db4objects.Db4o.Internal.Cluster; using Db4objects.Db4o.Internal.Query; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Internal.Cluster { /// public class ClusterQuery : IQuery { private readonly Db4objects.Db4o.Cluster.Cluster _cluster; private readonly IQuery[] _queries; public ClusterQuery(Db4objects.Db4o.Cluster.Cluster cluster, IQuery[] queries) { _cluster = cluster; _queries = queries; } public virtual IConstraint Constrain(object constraint) { lock (_cluster) { IConstraint[] constraints = new IConstraint[_queries.Length]; for (int i = 0; i < constraints.Length; i++) { constraints[i] = _queries[i].Constrain(constraint); } return new ClusterConstraint(_cluster, constraints); } } public virtual IConstraints Constraints() { lock (_cluster) { IConstraint[] constraints = new IConstraint[_queries.Length]; for (int i = 0; i < constraints.Length; i++) { constraints[i] = _queries[i].Constraints(); } return new ClusterConstraints(_cluster, constraints); } } public virtual IQuery Descend(string fieldName) { lock (_cluster) { IQuery[] queries = new IQuery[_queries.Length]; for (int i = 0; i < queries.Length; i++) { queries[i] = _queries[i].Descend(fieldName); } return new Db4objects.Db4o.Internal.Cluster.ClusterQuery(_cluster, queries); } } public virtual IObjectSet Execute() { lock (_cluster) { return new ObjectSetFacade(new ClusterQueryResult(_cluster, _queries)); } } public virtual IQuery OrderAscending() { throw new NotSupportedException(); } public virtual IQuery OrderDescending() { throw new NotSupportedException(); } public virtual IQuery SortBy(IQueryComparator comparator) { // FIXME throw new NotSupportedException(); } // FIXME } } src/Db4objects.Db4o.Optional/Db4objects.Db4o/Internal/Cluster/ClusterConstraints.cs000644 001750 001750 00000003000 11520622624 035335 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal.Cluster; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Internal.Cluster { /// public class ClusterConstraints : ClusterConstraint, IConstraints { public ClusterConstraints(Db4objects.Db4o.Cluster.Cluster cluster, IConstraint[] constraints) : base(cluster, constraints) { } public virtual IConstraint[] ToArray() { lock (_cluster) { Collection4 all = new Collection4(); for (int i = 0; i < _constraints.Length; i++) { ClusterConstraint c = (ClusterConstraint)_constraints[i]; for (int j = 0; j < c._constraints.Length; j++) { all.Add(c._constraints[j]); } } IConstraint[] res = new IConstraint[all.Size()]; all.ToArray(res); return res; } } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/000755 001750 001750 00000000000 11520622042 027404 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/000755 001750 001750 00000000000 11520622070 030276 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/SelfMethod.cs000644 001750 001750 00000001730 11520622624 032665 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Reflect; namespace Db4objects.Db4o.Reflect.Self { public class SelfMethod : IReflectMethod { public virtual object Invoke(object onObject, object[] parameters) { return null; } public virtual IReflectClass GetReturnType() { return null; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/FieldInfo.cs000644 001750 001750 00000002715 11520622624 032476 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Reflect.Self { public class FieldInfo { private string _name; private System.Type _clazz; private bool _isPublic; private bool _isStatic; private bool _isTransient; public FieldInfo(string name, System.Type clazz, bool isPublic, bool isStatic, bool isTransient) { _name = name; _clazz = clazz; _isPublic = isPublic; _isStatic = isStatic; _isTransient = isTransient; } public virtual string Name() { return _name; } public virtual System.Type Type() { return _clazz; } public virtual bool IsPublic() { return _isPublic; } public virtual bool IsStatic() { return _isStatic; } public virtual bool IsTransient() { return _isTransient; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/SelfField.cs000644 001750 001750 00000004343 11520622624 032473 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Self; namespace Db4objects.Db4o.Reflect.Self { public class SelfField : IReflectField { private string _name; private IReflectClass _type; private SelfClass _selfclass; private SelfReflectionRegistry _registry; public SelfField(string name, IReflectClass type, SelfClass selfclass, SelfReflectionRegistry registry) { _name = name; _type = type; _selfclass = selfclass; _registry = registry; } public virtual object Get(object onObject) { if (onObject is ISelfReflectable) { return ((ISelfReflectable)onObject).Self_get(_name); } return null; } public virtual string GetName() { return _name; } public virtual IReflectClass GetFieldType() { return _type; } public virtual bool IsPublic() { return _registry.InfoFor(_selfclass.GetJavaClass()).FieldByName(_name).IsPublic(); } public virtual bool IsStatic() { return _registry.InfoFor(_selfclass.GetJavaClass()).FieldByName(_name).IsStatic(); } public virtual bool IsTransient() { return _registry.InfoFor(_selfclass.GetJavaClass()).FieldByName(_name).IsTransient (); } public virtual void Set(object onObject, object value) { if (onObject is ISelfReflectable) { ((ISelfReflectable)onObject).Self_set(_name, value); } } public virtual object IndexEntry(object orig) { return orig; } public virtual IReflectClass IndexType() { return GetFieldType(); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/SelfClass.cs000644 001750 001750 00000011634 11520622624 032516 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Self; namespace Db4objects.Db4o.Reflect.Self { public class SelfClass : IReflectClass { private static readonly SelfField[] EmptyFields = new SelfField[0]; private bool _isAbstract; private SelfField[] _fields; private IReflector _parentReflector; private SelfReflectionRegistry _registry; private Type _class; private Type _superClass; public SelfClass(IReflector parentReflector, SelfReflectionRegistry registry, Type clazz) { // public SelfClass() { // super(); // } _parentReflector = parentReflector; _registry = registry; _class = clazz; } // TODO: Is this needed at all? public virtual Type GetJavaClass() { return _class; } public virtual IReflector Reflector() { return _parentReflector; } public virtual IReflectClass GetComponentType() { if (!IsArray()) { return null; } return _parentReflector.ForClass(_registry.ComponentType(_class)); } public virtual IReflectField[] GetDeclaredFields() { EnsureClassInfoLoaded(); return _fields; } private void EnsureClassInfoLoaded() { if (_fields == null) { ClassInfo classInfo = _registry.InfoFor(_class); if (classInfo == null) { _fields = EmptyFields; return; } _superClass = classInfo.SuperClass(); _isAbstract = classInfo.IsAbstract(); FieldInfo[] fieldInfo = classInfo.FieldInfo(); if (fieldInfo == null) { _fields = EmptyFields; return; } _fields = new SelfField[fieldInfo.Length]; for (int idx = 0; idx < fieldInfo.Length; idx++) { _fields[idx] = SelfFieldFor(fieldInfo[idx]); } } } public virtual IReflectField GetDeclaredField(string name) { EnsureClassInfoLoaded(); for (int idx = 0; idx < _fields.Length; idx++) { if (_fields[idx].GetName().Equals(name)) { return _fields[idx]; } } return null; } private SelfField SelfFieldFor(FieldInfo fieldInfo) { return new SelfField(fieldInfo.Name(), _parentReflector.ForClass(fieldInfo.Type() ), this, _registry); } public virtual IReflectClass GetDelegate() { return this; } public virtual IReflectMethod GetMethod(string methodName, IReflectClass[] paramClasses ) { // TODO !!!! return null; } public virtual string GetName() { return _class.FullName; } public virtual IReflectClass GetSuperclass() { EnsureClassInfoLoaded(); if (_superClass == null) { return null; } return _parentReflector.ForClass(_superClass); } public virtual bool IsAbstract() { EnsureClassInfoLoaded(); return _isAbstract || IsInterface(); } public virtual bool IsArray() { return _class.IsArray; } public virtual bool IsAssignableFrom(IReflectClass type) { if (!(type is Db4objects.Db4o.Reflect.Self.SelfClass)) { return false; } return _class.IsAssignableFrom(((Db4objects.Db4o.Reflect.Self.SelfClass)type).GetJavaClass ()); } public virtual bool IsCollection() { return _parentReflector.IsCollection(this); } public virtual bool IsInstance(object obj) { return _class.IsInstanceOfType(obj); } public virtual bool IsInterface() { return _class.IsInterface; } public virtual bool IsPrimitive() { return _registry.IsPrimitive(_class); } public virtual object NewInstance() { try { return System.Activator.CreateInstance(_class); } catch (Exception e) { Sharpen.Runtime.PrintStackTrace(e); } // Specialized exceptions break conversion to .NET // // // // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } return null; } public virtual object NullValue() { return null; } public virtual bool EnsureCanBeInstantiated() { return true; } public virtual bool IsImmutable() { return IsPrimitive() || Platform4.IsSimple(_class); } } } src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/ISelfReflectable.cs000644 001750 001750 00000001533 11520622624 033710 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Reflect.Self { public interface ISelfReflectable { object Self_get(string fieldName); void Self_set(string fieldName, object value); } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/SelfArray.cs000644 001750 001750 00000006452 11520622624 032531 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Self; using Sharpen; namespace Db4objects.Db4o.Reflect.Self { public class SelfArray : IReflectArray { private readonly SelfReflectionRegistry _registry; /// internal SelfArray(IReflector reflector, SelfReflectionRegistry registry) { _registry = registry; } public virtual void Analyze(object obj, ArrayInfo info) { } // do nothing public virtual int[] Dimensions(object arr) { return new int[] { GetLength(arr) }; } public virtual int Flatten(object a_shaped, int[] a_dimensions, int a_currentDimension , object[] a_flat, int a_flatElement) { if (a_shaped is object[]) { object[] shaped = (object[])a_shaped; System.Array.Copy(shaped, 0, a_flat, 0, shaped.Length); return shaped.Length; } return _registry.FlattenArray(a_shaped, a_flat); } public virtual object Get(object onArray, int index) { if (onArray is object[]) { return ((object[])onArray)[index]; } return _registry.GetArray(onArray, index); } public virtual IReflectClass GetComponentType(IReflectClass a_class) { return ((SelfClass)a_class).GetComponentType(); } public virtual int GetLength(object array) { if (array is object[]) { return ((object[])array).Length; } return _registry.ArrayLength(array); } public virtual bool IsNDimensional(IReflectClass a_class) { return false; } public virtual object NewInstance(IReflectClass componentType, ArrayInfo info) { // TODO: implement multidimensional arrays. int length = info.ElementCount(); return NewInstance(componentType, length); } public virtual object NewInstance(IReflectClass componentType, int length) { return _registry.ArrayFor(((SelfClass)componentType).GetJavaClass(), length); } public virtual object NewInstance(IReflectClass componentType, int[] dimensions) { return NewInstance(componentType, dimensions[0]); } public virtual void Set(object onArray, int index, object element) { if (onArray is object[]) { ((object[])onArray)[index] = element; return; } _registry.SetArray(onArray, index, element); } public virtual int Shape(object[] a_flat, int a_flatElement, object a_shaped, int [] a_dimensions, int a_currentDimension) { if (a_shaped is object[]) { object[] shaped = (object[])a_shaped; System.Array.Copy(a_flat, 0, shaped, 0, a_flat.Length); return a_flat.Length; } return _registry.ShapeArray(a_flat, a_shaped); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/SelfReflector.cs000644 001750 001750 00000004105 11520622624 033371 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Self; namespace Db4objects.Db4o.Reflect.Self { public class SelfReflector : IReflector { private SelfArray _arrayHandler; private SelfReflectionRegistry _registry; private IReflector _parent; public SelfReflector(SelfReflectionRegistry registry) { _registry = registry; } public virtual IReflectArray Array() { if (_arrayHandler == null) { _arrayHandler = new SelfArray(this, _registry); } return _arrayHandler; } public virtual IReflectClass ForClass(Type clazz) { return new SelfClass(_parent, _registry, clazz); } public virtual IReflectClass ForName(string className) { Type clazz = ReflectPlatform.ForName(className); return ForClass(clazz); } public virtual IReflectClass ForObject(object a_object) { if (a_object == null) { return null; } return _parent.ForClass(a_object.GetType()); } public virtual bool IsCollection(IReflectClass claxx) { return false; } public virtual void SetParent(IReflector reflector) { _parent = reflector; } public virtual object DeepClone(object context) { return new Db4objects.Db4o.Reflect.Self.SelfReflector(_registry); } public virtual void Configuration(IReflectorConfiguration config) { } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/ClassInfo.cs000644 001750 001750 00000003211 11520622624 032510 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4objects.Db4o.Reflect.Self { public class ClassInfo { private Type _superClass; private bool _isAbstract; private Db4objects.Db4o.Reflect.Self.FieldInfo[] _fieldInfo; public ClassInfo(bool isAbstract, Type superClass, Db4objects.Db4o.Reflect.Self.FieldInfo [] fieldInfo) { _isAbstract = isAbstract; _superClass = superClass; _fieldInfo = fieldInfo; } public virtual bool IsAbstract() { return _isAbstract; } public virtual Type SuperClass() { return _superClass; } public virtual Db4objects.Db4o.Reflect.Self.FieldInfo[] FieldInfo() { return _fieldInfo; } public virtual Db4objects.Db4o.Reflect.Self.FieldInfo FieldByName(string name) { if (!(_fieldInfo.Length == 0)) { for (int i = 0; i < _fieldInfo.Length; i++) { if (_fieldInfo[i].Name().Equals(name)) { return _fieldInfo[i]; } } } return null; } } } src/Db4objects.Db4o.Optional/Db4objects.Db4o/Reflect/Self/SelfReflectionRegistry.cs000644 001750 001750 00000021157 11520622624 035216 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Reflect.Self; namespace Db4objects.Db4o.Reflect.Self { /// /// Contains the application-specific reflection information (that would /// be generated by a bytecode enhancer), as opposed to the 'generic' /// functionality contained in SelfReflector. /// /// /// Contains the application-specific reflection information (that would /// be generated by a bytecode enhancer), as opposed to the 'generic' /// functionality contained in SelfReflector. /// public abstract class SelfReflectionRegistry { private static readonly Type[] Arraytypes = new Type[] { typeof(int[]), typeof(long []), typeof(short[]), typeof(char[]), typeof(byte[]), typeof(bool[]), typeof(float []), typeof(double[]), typeof(string[]) }; private static readonly Type[] Primitives = new Type[] { typeof(int), typeof(long ), typeof(short), typeof(char), typeof(byte), typeof(bool), typeof(float), typeof( double), typeof(string) }; public virtual bool IsPrimitive(Type clazz) { for (int idx = 0; idx < Primitives.Length; idx++) { if (Primitives[idx].Equals(clazz)) { return true; } } return false; } public abstract ClassInfo InfoFor(Type clazz); public virtual object ArrayFor(Type clazz, int length) { if (typeof(int).IsAssignableFrom(clazz) || typeof(int).IsAssignableFrom(clazz)) { return new int[length]; } if (typeof(long).IsAssignableFrom(clazz) || typeof(long).IsAssignableFrom(clazz)) { return new long[length]; } if (typeof(short).IsAssignableFrom(clazz) || typeof(short).IsAssignableFrom(clazz )) { return new short[length]; } if (typeof(bool).IsAssignableFrom(clazz) || typeof(bool).IsAssignableFrom(clazz)) { return new bool[length]; } if (typeof(byte).IsAssignableFrom(clazz) || typeof(byte).IsAssignableFrom(clazz)) { return new byte[length]; } if (typeof(char).IsAssignableFrom(clazz) || typeof(char).IsAssignableFrom(clazz)) { return new char[length]; } if (typeof(float).IsAssignableFrom(clazz) || typeof(float).IsAssignableFrom(clazz )) { return new float[length]; } if (typeof(double).IsAssignableFrom(clazz) || typeof(double).IsAssignableFrom(clazz )) { return new double[length]; } if (typeof(string).IsAssignableFrom(clazz)) { return new string[length]; } return null; } public virtual Type ComponentType(Type clazz) { for (int i = 0; i < Arraytypes.Length; i++) { if (Arraytypes[i].Equals(clazz)) { return Primitives[i]; } } return null; } public virtual int ArrayLength(object array) { if (array is bool[]) { return ((bool[])array).Length; } if (array is byte[]) { return ((byte[])array).Length; } if (array is short[]) { return ((short[])array).Length; } if (array is char[]) { return ((char[])array).Length; } if (array is int[]) { return ((int[])array).Length; } if (array is long[]) { return ((long[])array).Length; } if (array is float[]) { return ((float[])array).Length; } if (array is double[]) { return ((double[])array).Length; } return 0; } public virtual void SetArray(object array, int index, object element) { if (array is bool[]) { ((bool[])array)[index] = ((bool)element); } if (array is byte[]) { ((byte[])array)[index] = ((byte)element); } if (array is short[]) { ((short[])array)[index] = ((short)element); } if (array is char[]) { ((char[])array)[index] = ((char)element); } if (array is int[]) { ((int[])array)[index] = ((int)element); } if (array is long[]) { ((long[])array)[index] = ((long)element); } if (array is float[]) { ((float[])array)[index] = ((float)element); } if (array is double[]) { ((double[])array)[index] = ((double)element); } } public virtual object GetArray(object array, int index) { if (array is bool[]) { return ((bool[])array)[index]; } if (array is byte[]) { return ((byte[])array)[index]; } if (array is short[]) { return ((short[])array)[index]; } if (array is char[]) { return ((char[])array)[index]; } if (array is int[]) { return ((int[])array)[index]; } if (array is long[]) { return ((long[])array)[index]; } if (array is float[]) { return ((float[])array)[index]; } if (array is double[]) { return ((double[])array)[index]; } return null; } public virtual int FlattenArray(object array, object[] a_flat) { if (array is bool[]) { bool[] shaped = (bool[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is byte[]) { byte[] shaped = (byte[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is short[]) { short[] shaped = (short[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is char[]) { char[] shaped = (char[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is int[]) { int[] shaped = (int[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is long[]) { long[] shaped = (long[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is float[]) { float[] shaped = (float[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } if (array is double[]) { double[] shaped = (double[])array; for (int i = 0; i < shaped.Length; i++) { a_flat[i] = shaped[i]; } return shaped.Length; } return 0; } public virtual int ShapeArray(object[] a_flat, object array) { if (array is bool[]) { bool[] shaped = (bool[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((bool)a_flat[i]); } return a_flat.Length; } if (array is byte[]) { byte[] shaped = (byte[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((byte)a_flat[i]); } return a_flat.Length; } if (array is short[]) { short[] shaped = (short[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((short)a_flat[i]); } return a_flat.Length; } if (array is char[]) { char[] shaped = (char[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((char)a_flat[i]); } return a_flat.Length; } if (array is int[]) { int[] shaped = (int[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((int)a_flat[i]); } return a_flat.Length; } if (array is long[]) { long[] shaped = (long[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((long)a_flat[i]); } return a_flat.Length; } if (array is float[]) { float[] shaped = (float[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((float)a_flat[i]); } return a_flat.Length; } if (array is double[]) { double[] shaped = (double[])array; for (int i = 0; i < shaped.Length; i++) { shaped[i] = ((double)a_flat[i]); } return a_flat.Length; } return 0; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Makefile000644 001750 001750 00000000167 11520622050 024711 0ustar00directhexdirecthex000000 000000 include ../include.mk TARGET = library ASSEMBLY = $(OPTIONAL) REFERENCES = -r:$(OUTDIR)/$(CORE) -r:$(OUTDIR)/$(CS) db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Properties/000755 001750 001750 00000000000 11520622044 025404 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Optional/Properties/AssemblyInfo.cs000644 001750 001750 00000002624 11520622624 030336 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using System.Security; [assembly: AssemblyTitle("db4o - optional functionality")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // attributes are automatically set by the build [assembly: AssemblyVersion("8.0.184.15484")] [assembly: AssemblyKeyFile("")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyDescription("Db4objects.Db4o.Optional 8.0.184.15484 (.NET)")] #if !CF && !SILVERLIGHT [assembly: AllowPartiallyTrustedCallers] #endif [assembly: CLSCompliant(true)]db4o-8.0.184.15484+dfsg/src/db4objects.snk000644 001750 001750 00000001124 11520622052 021447 0ustar00directhexdirecthex000000 000000 $RSA2Ho* d(FrOycbq5rg% Z-چ W>c$Q3lȞP )Ț}$DP~ǔi{qy< zB'PV8QNb|fxP_IWy;k=3hveƯ0:_Vwo0ش%VyUBqabBNTYu&բX6] 6:.eƈ'I8XK백3m[yCYp%\')s'F#6Hv Lڂ QRWܚ#RuA%0,J:0G];1Gscwm6}$Md-̜\5\j1ǵCp8rPN.?x;v|z9?HB6dﲻ8bSሹlłN? .J'3uΞ{EY?pr>n.=nOq LR웜e>vdb4o-8.0.184.15484+dfsg/src/Db4o-2008.sln000644 001750 001750 00000023416 11520622050 020612 0ustar00directhexdirecthex000000 000000  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq.Tests-2008", "Db4objects.Db4o.Linq.Tests\Db4objects.Db4o.Linq.Tests-2008.csproj", "{22AB6F58-39BF-4580-821B-5900E31AC33A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq-2008", "Db4objects.Db4o.Linq\Db4objects.Db4o.Linq-2008.csproj", "{23531440-0922-43EB-A483-6592FFC2F093}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-2008", "Db4objects.Db4o\Db4objects.Db4o-2008.csproj", "{600CD3BF-2ED2-4183-87F7-ADD78A968AE0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit-2008", "Db4oUnit\Db4oUnit-2008.csproj", "{8F82F8B0-95B6-4553-BDA8-BD9A954E682F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit.Extensions-2008", "Db4oUnit.Extensions\Db4oUnit.Extensions-2008.csproj", "{9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.NativeQueries-2008", "Db4objects.Db4o.NativeQueries\Db4objects.Db4o.NativeQueries-2008.csproj", "{AB1BF369-A9C4-4876-9797-178DB8AD437F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Instrumentation-2008", "Db4objects.Db4o.Instrumentation\Db4objects.Db4o.Instrumentation-2008.csproj", "{FFA59708-14D1-4C22-B9A4-1A389EE796D5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Tests-2008", "Db4objects.Db4o.Tests\Db4objects.Db4o.Tests-2008.csproj", "{7FBF7399-7815-4AC2-8DE8-B21AA8FE9048}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oTool-2008", "Db4oTool\Db4oTool\Db4oTool-2008.csproj", "{6F3BE659-0653-4982-94D6-F1D9D8887E09}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oTool.Tests-2008", "Db4oTool\Db4oTool.Tests\Db4oTool.Tests-2008.csproj", "{69859DB2-4DE3-4DE4-A0BB-13861418378F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq.Instrumentation.Tests", "Db4objects.Db4o.Linq.Instrumentation.Tests\Db4objects.Db4o.Linq.Instrumentation.Tests.csproj", "{34A9FF31-90E6-4C19-AD64-3C4512C521FE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oBench-2008", "Db4oBench\Db4oBench-2008.csproj", "{D8AB00B9-7769-4136-98FA-920F89B12653}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Db4objects.Db4o.Linq.VB.Tests", "Db4objects.Db4o.Linq.VB.Tests\Db4objects.Db4o.Linq.VB.Tests.vbproj", "{1B1EA933-A4CF-40EA-91F8-0C359242B6B4}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CS-2008", "Db4objects.Db4o.CS\Db4objects.Db4o.CS-2008.csproj", "{9FA8178A-3E77-42C5-A252-6690EA9BA257}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Optional-2008", "Db4objects.Db4o.Optional\Db4objects.Db4o.Optional-2008.csproj", "{E9588FE7-C19D-445E-BB53-AE539EA4F0E6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Data.Services-2008", "Db4objects.Db4o.Data.Services\Db4objects.Db4o.Data.Services-2008.csproj", "{8DA7BEBC-170D-4F66-A215-6B3BDF73795F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Data.Services.Tests-2008", "Db4objects.Db4o.Data.Services.Tests\Db4objects.Db4o.Data.Services.Tests-2008.csproj", "{27FDA74C-DDA4-41E0-838A-660B22283B7C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CS.Optional-2008", "Db4objects.Db4o.CS.Optional\Db4objects.Db4o.CS.Optional-2008.csproj", "{2DC5A1FA-7BD9-4937-9E36-2EED126B7809}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {22AB6F58-39BF-4580-821B-5900E31AC33A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Debug|Any CPU.Build.0 = Debug|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Release|Any CPU.ActiveCfg = Release|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Release|Any CPU.Build.0 = Release|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Debug|Any CPU.Build.0 = Debug|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Release|Any CPU.ActiveCfg = Release|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Release|Any CPU.Build.0 = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.Build.0 = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.Build.0 = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.Build.0 = Release|Any CPU {AB1BF369-A9C4-4876-9797-178DB8AD437F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AB1BF369-A9C4-4876-9797-178DB8AD437F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AB1BF369-A9C4-4876-9797-178DB8AD437F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AB1BF369-A9C4-4876-9797-178DB8AD437F}.Release|Any CPU.Build.0 = Release|Any CPU {FFA59708-14D1-4C22-B9A4-1A389EE796D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FFA59708-14D1-4C22-B9A4-1A389EE796D5}.Debug|Any CPU.Build.0 = Debug|Any CPU {FFA59708-14D1-4C22-B9A4-1A389EE796D5}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFA59708-14D1-4C22-B9A4-1A389EE796D5}.Release|Any CPU.Build.0 = Release|Any CPU {7FBF7399-7815-4AC2-8DE8-B21AA8FE9048}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7FBF7399-7815-4AC2-8DE8-B21AA8FE9048}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FBF7399-7815-4AC2-8DE8-B21AA8FE9048}.Release|Any CPU.ActiveCfg = Release|Any CPU {7FBF7399-7815-4AC2-8DE8-B21AA8FE9048}.Release|Any CPU.Build.0 = Release|Any CPU {6F3BE659-0653-4982-94D6-F1D9D8887E09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6F3BE659-0653-4982-94D6-F1D9D8887E09}.Debug|Any CPU.Build.0 = Debug|Any CPU {6F3BE659-0653-4982-94D6-F1D9D8887E09}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F3BE659-0653-4982-94D6-F1D9D8887E09}.Release|Any CPU.Build.0 = Release|Any CPU {69859DB2-4DE3-4DE4-A0BB-13861418378F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69859DB2-4DE3-4DE4-A0BB-13861418378F}.Debug|Any CPU.Build.0 = Debug|Any CPU {69859DB2-4DE3-4DE4-A0BB-13861418378F}.Release|Any CPU.ActiveCfg = Release|Any CPU {69859DB2-4DE3-4DE4-A0BB-13861418378F}.Release|Any CPU.Build.0 = Release|Any CPU {34A9FF31-90E6-4C19-AD64-3C4512C521FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {34A9FF31-90E6-4C19-AD64-3C4512C521FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {34A9FF31-90E6-4C19-AD64-3C4512C521FE}.Release|Any CPU.ActiveCfg = Release|Any CPU {34A9FF31-90E6-4C19-AD64-3C4512C521FE}.Release|Any CPU.Build.0 = Release|Any CPU {D8AB00B9-7769-4136-98FA-920F89B12653}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D8AB00B9-7769-4136-98FA-920F89B12653}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8AB00B9-7769-4136-98FA-920F89B12653}.Release|Any CPU.ActiveCfg = Release|Any CPU {D8AB00B9-7769-4136-98FA-920F89B12653}.Release|Any CPU.Build.0 = Release|Any CPU {1B1EA933-A4CF-40EA-91F8-0C359242B6B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1B1EA933-A4CF-40EA-91F8-0C359242B6B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B1EA933-A4CF-40EA-91F8-0C359242B6B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B1EA933-A4CF-40EA-91F8-0C359242B6B4}.Release|Any CPU.Build.0 = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.ActiveCfg = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.Build.0 = Release|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Release|Any CPU.Build.0 = Release|Any CPU {8DA7BEBC-170D-4F66-A215-6B3BDF73795F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8DA7BEBC-170D-4F66-A215-6B3BDF73795F}.Debug|Any CPU.Build.0 = Debug|Any CPU {8DA7BEBC-170D-4F66-A215-6B3BDF73795F}.Release|Any CPU.ActiveCfg = Release|Any CPU {8DA7BEBC-170D-4F66-A215-6B3BDF73795F}.Release|Any CPU.Build.0 = Release|Any CPU {27FDA74C-DDA4-41E0-838A-660B22283B7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {27FDA74C-DDA4-41E0-838A-660B22283B7C}.Debug|Any CPU.Build.0 = Debug|Any CPU {27FDA74C-DDA4-41E0-838A-660B22283B7C}.Release|Any CPU.ActiveCfg = Release|Any CPU {27FDA74C-DDA4-41E0-838A-660B22283B7C}.Release|Any CPU.Build.0 = Release|Any CPU {2DC5A1FA-7BD9-4937-9E36-2EED126B7809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DC5A1FA-7BD9-4937-9E36-2EED126B7809}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DC5A1FA-7BD9-4937-9E36-2EED126B7809}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DC5A1FA-7BD9-4937-9E36-2EED126B7809}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/000755 001750 001750 00000000000 11520622056 025533 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Desktop/000755 001750 001750 00000000000 11520622070 027140 5ustar00directhexdirecthex000000 000000 Db4objects.Db4o.CFCompatibilityTests/Desktop/Db4objects.Db4o.CFCompatibilityTests.Desktop-2008.sln000644 001750 001750 00000003767 11520622056 040435 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CFCompatibilityTests.Desktop-2008", "Db4objects.Db4o.CFCompatibilityTests.Desktop-2008.csproj", "{5981C78B-2275-4750-B283-1937475F5834}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-2008", "..\..\Db4objects.Db4o\Db4objects.Db4o-2008.csproj", "{600CD3BF-2ED2-4183-87F7-ADD78A968AE0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Subject-2008", "..\Db4objects.Db4o.CFCompatibilityTests.Subject\Tests.Subject-2008.csproj", "{C43A42ED-7AF1-4E57-B207-6DEFE08C2E63}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {5981C78B-2275-4750-B283-1937475F5834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5981C78B-2275-4750-B283-1937475F5834}.Debug|Any CPU.Build.0 = Debug|Any CPU {5981C78B-2275-4750-B283-1937475F5834}.Release|Any CPU.ActiveCfg = Release|Any CPU {5981C78B-2275-4750-B283-1937475F5834}.Release|Any CPU.Build.0 = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.Build.0 = Release|Any CPU {C43A42ED-7AF1-4E57-B207-6DEFE08C2E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C43A42ED-7AF1-4E57-B207-6DEFE08C2E63}.Debug|Any CPU.Build.0 = Debug|Any CPU {C43A42ED-7AF1-4E57-B207-6DEFE08C2E63}.Release|Any CPU.ActiveCfg = Release|Any CPU {C43A42ED-7AF1-4E57-B207-6DEFE08C2E63}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Desktop/Program.cs000644 001750 001750 00000007240 11520622622 031104 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.IO; using Tests.Subject; namespace Db4objects.Db4o.CFCompatibilityTests { class Program { public static int Main(string[] args) { if (args.Length < 2) { Console.Error.WriteLine("Db4objects.Db4o.CFCompatibilityTests.Desktop -generateDatabase|-validateDatabase "); return -1; } string databaseFile = args[1]; switch(args[0]) { case "-generateDatabase": GenerateDatabase(databaseFile); return 0; case "-validateDatabase": return ValidateDatabase(databaseFile); } Console.Error.WriteLine("Invalid parameter: {0}", args[0]); return -2; } private static int ValidateDatabase(string databaseFile) { int errorCount = 0; using (IObjectContainer db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), databaseFile)) { IList> results = db.Query>(delegate(CFCompatibilityTestSubject candidate) { return candidate._name == "foo"; }); if (results.Count > 0) { Console.Error.WriteLine("Object with name 'foo' should be deleted but still exists in db."); errorCount++; } const string johnDoeName = "john.doe"; CFCompatibilityTestSubject subject = RetrieveOnlyInstance(db, johnDoeName); if (null == subject) { errorCount++; } CFCompatibilityTestSubject expected = Subjects.NewJohnDoe(); if (!expected.Equals(subject)) { Console.Error.WriteLine("Expected {0} but got {1}", expected, subject != null ? subject.ToString() : "null"); errorCount++; } subject = RetrieveOnlyInstance(db, "foobar"); if (null == subject) { errorCount++; } if (!Subjects.Item("bar").Equals(subject._child)) { Console.Error.WriteLine("Foo._child expected to be {0} but was {1}", Subjects.Item("bar"), subject._child); errorCount++; } } return errorCount; } private static CFCompatibilityTestSubject RetrieveOnlyInstance(IObjectContainer db, string name) { IList> results = db.Query>(delegate(CFCompatibilityTestSubject candidate) { return candidate._name == name; }); if (results.Count != 1) { Console.Error.WriteLine("Expected one instance of '{0}' but found '{1}'", name, results.Count); return null; } return results[0]; } private static void GenerateDatabase(string databaseFile) { if (File.Exists(databaseFile)) { File.Delete(databaseFile); } Console.Error.WriteLine("Generating database: {0}", databaseFile); using (IObjectContainer db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), databaseFile)) { foreach (CFCompatibilityTestSubject subject in Subjects.Objects) { db.Store(subject); } } } } }db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Desktop/Properties/000755 001750 001750 00000000000 11520622060 031273 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Desktop/Properties/AssemblyInfo.cs000644 001750 001750 00000004310 11520622622 034217 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Db4objects.Db4o.CFCompatibilityTests.Desktop")] [assembly: AssemblyDescription("Desktop 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c5bfe876-92d8-49af-b4c7-351534b52b33")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("8.0.184.15484")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("8.0.184.15484")] Desktop/Db4objects.Db4o.CFCompatibilityTests.Desktop-2008.csproj000644 001750 001750 00000005310 11520622070 041117 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests Debug AnyCPU 9.0.30729 2.0 {5981C78B-2275-4750-B283-1937475F5834} Exe Properties Db4objects.Db4o.CFCompatibilityTests CFCompatibilityTests.Desktop v3.5 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 3.5 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 {C43A42ED-7AF1-4E57-B207-6DEFE08C2E63} Tests.Subject-2008 src/Db4objects.Db4o.CFCompatibilityTests/Db4objects.Db4o.CFCompatibilityTests.Subject/000755 001750 001750 00000000000 11520622070 035664 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgDb4objects.Db4o.CFCompatibilityTests.Subject/CFCompatibilityTestSubject.cs000644 001750 001750 00000013325 11520622622 043424 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; namespace Tests.Subject { public class CFCompatibilityTestSubject : BaseType where T : IComparable { public CFCompatibilityTestSubject(string name) : base(name) { } public IList _ids; public long[] _longs; public DateTime _dateTime; public Nullable[] _nullables; public CFCompatibilityTestSubject _child; public CFCompatibilityTestSubject Longs(params long[] longs) { _longs = longs; return this; } public CFCompatibilityTestSubject DateTime(DateTime dateTime) { _dateTime = dateTime; return this; } public CFCompatibilityTestSubject NullableInts(params int?[] values) { _nullables = values; return this; } public CFCompatibilityTestSubject List(params T[] ids) { _ids = new List(ids); return this; } public CFCompatibilityTestSubject Child(CFCompatibilityTestSubject child) { _child = child; return this; } public override bool Equals(object obj) { CFCompatibilityTestSubject lhs = obj as CFCompatibilityTestSubject; if (null == lhs) return false; if (lhs.GetType() != GetType()) return false; return Equals(lhs._child, _child) && lhs._dateTime == _dateTime && lhs._name == _name && AreEqual(lhs._ids, _ids) && AreEqual(lhs._longs, _longs); } public override string ToString() { return "CFCompatibilityTest<" + GetType().GetGenericArguments()[0].Name + ">\r\n(\r\n" + "\tName: " + _name + "\r\n" + "\tDateTime: " + _dateTime + "\r\n" + "\tIds: " + _ids + "\r\n" + "\tLongs: " + _longs + "\r\n" + "\tNullables: " + _nullables + "\r\n" + "\tChild: " + _child + ")\r\n"; } private static bool AreEqual(IEnumerable lhs, IEnumerable rhs) where E : IComparable { if (rhs == lhs) return true; if (null == lhs) return false; if (null == rhs) return false; IEnumerator e1 = lhs.GetEnumerator(); IEnumerator e2 = rhs.GetEnumerator(); while (e1.MoveNext()) { if (!e2.MoveNext()) { return false; } if (!Equals(e1.Current, e2.Current)) { return false; } } return !e2.MoveNext(); } } public class BaseType { public BaseType(string name) { _name = name; } public string _name; } public class Subjects { private static readonly IDictionary> _subjects; static Subjects() { _subjects = new Dictionary>(); foreach (CFCompatibilityTestSubject subject in SubjectsToTest()) { _subjects[subject._name] = subject; } } public static CFCompatibilityTestSubject Item(string name) { return _subjects[name]; } public static IEnumerable> Objects { get { return _subjects.Values; } } private static IEnumerable> SubjectsToTest() { DateTime vid = new DateTime(1971, 5, 1); yield return new CFCompatibilityTestSubject("foo"). List(string.Empty, "foo.2", "foo.3"). Longs(long.MinValue, 0, long.MaxValue). DateTime(vid). NullableInts(int.MinValue, 0, int.MaxValue, null); yield return new CFCompatibilityTestSubject("bar"). List("bar.1", string.Empty, "bar.3"). Longs(). DateTime(vid). NullableInts(null); DateTime vid2 = new DateTime(1998, 5, 1); CFCompatibilityTestSubject baz = new CFCompatibilityTestSubject("baz"). List("baz.1", "baz.2", string.Empty). Longs(). DateTime(vid2). NullableInts(vid2.Day, vid2.Month, vid2.Year); yield return baz; yield return new CFCompatibilityTestSubject("foobar"). List(string.Empty, "foobar.2", "foobar.3"). Longs(). DateTime(DateTime.MaxValue). NullableInts(null). Child(baz); } public static CFCompatibilityTestSubject NewJohnDoe() { return new CFCompatibilityTestSubject("john.doe"). List("john.doe.1", "john.doe.2", "john.doe.3"). Longs(). DateTime(DateTime.MinValue). NullableInts(null); } } }Db4objects.Db4o.CFCompatibilityTests.Subject/Tests.Subject-2008.csproj000644 001750 001750 00000004732 11520622070 042203 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests Debug AnyCPU 9.0.30729 2.0 {C43A42ED-7AF1-4E57-B207-6DEFE08C2E63} Library Properties Tests.Subject Tests.Subject v3.5 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 3.5 3.5 3.5 src/Db4objects.Db4o.CFCompatibilityTests/Db4objects.Db4o.CFCompatibilityTests.Subject/Properties/000755 001750 001750 00000000000 11520622052 040020 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgDb4objects.Db4o.CFCompatibilityTests.Subject/Properties/AssemblyInfo.cs000644 001750 001750 00000004222 11520622622 042745 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Db4objects.Db4o.CFCompatibilityTests.Subject")] [assembly: AssemblyDescription("Db4objects.Db4o.CFCompatibilityTests.Subject 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("f29d79c8-b03a-49dd-835b-b6ba852c1092")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("8.0.184.15484")] Db4objects.Db4o.CFCompatibilityTests.Subject/Tests.Subject-CF-2008.csproj000644 001750 001750 00000006447 11520622064 042501 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests Debug AnyCPU 9.0.30729 2.0 {7F388726-A3A0-4CF7-89F4-52926EA02D55} Library Properties Tests.Subject Tests.Subject {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 4118C335-430C-497f-BE48-11C3316B135E 5.1 Db4objects.Db4o.CFCompatibilityTests.Subject v3.5 Windows Mobile 5.0 Pocket PC SDK true full false bin\Debug\ DEBUG;TRACE;$(PlatformFamilyName) true true prompt 512 4 Off pdbonly true bin\Release\ TRACE;$(PlatformFamilyName) true true prompt 512 4 Off db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/000755 001750 001750 00000000000 11520622066 026733 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Console.Designer.cs000644 001750 001750 00000003757 11520622622 032435 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.CFCompatibilityTests.Device { partial class Console { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; private System.Windows.Forms.MainMenu mainMenu1; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.SuspendLayout(); // // Console // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScroll = true; this.ClientSize = new System.Drawing.Size(240, 268); this.Menu = this.mainMenu1; this.Name = "Console"; this.Text = "Console"; this.ResumeLayout(false); } #endregion } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Console.cs000644 001750 001750 00000007012 11520622622 030662 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Windows.Forms; using Tests.Subject; using Db4oUnit; namespace Db4objects.Db4o.CFCompatibilityTests.Device { public partial class Console : Form { public Console(string []args) { InitializeComponent(); DatabasePath = args[0]; _result = new ConsoleTestRunner(CFCompatibilityTests()).Run(); Close(); } private static IEnumerator CFCompatibilityTests() { return new ReflectionTestSuiteBuilder( new Type[] { typeof(CFCompatibilityTestCase), typeof(CFCompatibilityDefragTestCase), }).GetEnumerator(); } public int Result { get { return _result; } } internal static string DatabasePath { get { return _databaseFile; } set { _databaseFile = value; } } private static string _databaseFile; private readonly int _result; } internal class CFCompatibilityDefragTestCase : ITestCase { public void TestDefragment() { string backupFile = Console.DatabasePath + "." + Defragment.DefragmentConfig.BackupSuffix; if (File.Exists(backupFile)) { File.Delete(backupFile); } Defragment.Defragment.Defrag(Console.DatabasePath); } } /** * We don't support (and therefore don't test) from Desktop -> CF * * - Database version updates * - * * */ internal class CFCompatibilityTestCase : ITestLifeCycle { public void TestQuery() { AssertSubject("bar"); } public void TestUpdate() { CFCompatibilityTestSubject foobar = AssertSubject("foobar"); Assert.AreEqual(Subjects.Item("baz"), foobar._child); foobar.Child(RetrieveOnlyInstance("bar")); Db().Store(foobar); } public void TestInsert() { Db().Store(Subjects.NewJohnDoe()); } public void TestDelete() { Db().Delete(RetrieveOnlyInstance("foo")); } private CFCompatibilityTestSubject AssertSubject(string name) { CFCompatibilityTestSubject instance = RetrieveOnlyInstance(name); Assert.AreEqual(Subjects.Item(name), instance); return instance; } private CFCompatibilityTestSubject RetrieveOnlyInstance(string name) { IList> results = Db().Query>(delegate(CFCompatibilityTestSubject candidate) { return candidate._name == name; }); Assert.AreEqual(1, results.Count); return results[0]; } public void SetUp() { _db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), Console.DatabasePath); } public void TearDown() { _db.Close(); } private IObjectContainer Db() { return _db; } private IObjectContainer _db; } }src/Db4objects.Db4o.CFCompatibilityTests/Device/Db4objects.Db4o.CFCompatibilityTests.Device-2008.sln000644 001750 001750 00000010346 11520622062 037775 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CFCompatibilityTests.Device-2008", "Db4objects.Db4o.CFCompatibilityTests.Device-2008.csproj", "{67F731E8-692E-4F4C-AF97-E50A5A117A84}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-CF-2008", "..\..\Db4objects.Db4o\Db4objects.Db4o-CF-2008.csproj", "{95FD1C64-F1A3-4C8A-B170-D518E899B2FE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit-CF-2008", "..\..\Db4oUnit\Db4oUnit-CF-2008.csproj", "{7C7F460A-A3A0-40D5-872C-B7BA617F9BA7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit.Extensions-CF-2008", "..\..\Db4oUnit.Extensions\Db4oUnit.Extensions-CF-2008.csproj", "{6C7B5203-2178-4BFC-B8AB-D387D7C28A65}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Subject-CF-2008", "..\Db4objects.Db4o.CFCompatibilityTests.Subject\Tests.Subject-CF-2008.csproj", "{7F388726-A3A0-4CF7-89F4-52926EA02D55}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CS-CF-2008", "..\..\Db4objects.Db4o.CS\Db4objects.Db4o.CS-CF-2008.csproj", "{89BB3D10-B9D5-4172-A0D9-3BB856AC5B85}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Optional-CF-2008", "..\..\Db4objects.Db4o.Optional\Db4objects.Db4o.Optional-CF-2008.csproj", "{667C616E-FEA2-4D5E-93F0-9D18D17275FA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {67F731E8-692E-4F4C-AF97-E50A5A117A84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {67F731E8-692E-4F4C-AF97-E50A5A117A84}.Debug|Any CPU.Build.0 = Debug|Any CPU {67F731E8-692E-4F4C-AF97-E50A5A117A84}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {67F731E8-692E-4F4C-AF97-E50A5A117A84}.Release|Any CPU.ActiveCfg = Release|Any CPU {67F731E8-692E-4F4C-AF97-E50A5A117A84}.Release|Any CPU.Build.0 = Release|Any CPU {67F731E8-692E-4F4C-AF97-E50A5A117A84}.Release|Any CPU.Deploy.0 = Release|Any CPU {95FD1C64-F1A3-4C8A-B170-D518E899B2FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95FD1C64-F1A3-4C8A-B170-D518E899B2FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {95FD1C64-F1A3-4C8A-B170-D518E899B2FE}.Release|Any CPU.ActiveCfg = Release|Any CPU {95FD1C64-F1A3-4C8A-B170-D518E899B2FE}.Release|Any CPU.Build.0 = Release|Any CPU {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7}.Release|Any CPU.Build.0 = Release|Any CPU {6C7B5203-2178-4BFC-B8AB-D387D7C28A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6C7B5203-2178-4BFC-B8AB-D387D7C28A65}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C7B5203-2178-4BFC-B8AB-D387D7C28A65}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C7B5203-2178-4BFC-B8AB-D387D7C28A65}.Release|Any CPU.Build.0 = Release|Any CPU {7F388726-A3A0-4CF7-89F4-52926EA02D55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F388726-A3A0-4CF7-89F4-52926EA02D55}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F388726-A3A0-4CF7-89F4-52926EA02D55}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F388726-A3A0-4CF7-89F4-52926EA02D55}.Release|Any CPU.Build.0 = Release|Any CPU {89BB3D10-B9D5-4172-A0D9-3BB856AC5B85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {89BB3D10-B9D5-4172-A0D9-3BB856AC5B85}.Debug|Any CPU.Build.0 = Debug|Any CPU {89BB3D10-B9D5-4172-A0D9-3BB856AC5B85}.Release|Any CPU.ActiveCfg = Release|Any CPU {89BB3D10-B9D5-4172-A0D9-3BB856AC5B85}.Release|Any CPU.Build.0 = Release|Any CPU {667C616E-FEA2-4D5E-93F0-9D18D17275FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {667C616E-FEA2-4D5E-93F0-9D18D17275FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {667C616E-FEA2-4D5E-93F0-9D18D17275FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {667C616E-FEA2-4D5E-93F0-9D18D17275FA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Program.cs000644 001750 001750 00000002042 11520622622 030665 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Windows.Forms; namespace Db4objects.Db4o.CFCompatibilityTests.Device { static class Program { /// /// The main entry point for the application. /// [MTAThread] static int Main(string[] args) { Console console = new Console(args); Application.Run(console); return console.Result; } } }db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Console.resx000644 001750 001750 00000014252 11520622054 031241 0ustar00directhexdirecthex000000 000000 text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 17, 17 POCKET_PC_2003_PORTRAIT True db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Properties/000755 001750 001750 00000000000 11520622070 031062 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.CFCompatibilityTests/Device/Properties/Resources.Designer.cs000644 001750 001750 00000005433 11520622622 035053 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.CFCompatibilityTests.Device.Properties { using System; /// /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Db4objects.Db4o.CFCompatibilityTests.Device.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Properties/Resources.resx000644 001750 001750 00000012762 11520622066 033754 0ustar00directhexdirecthex000000 000000  text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CFCompatibilityTests/Device/Properties/AssemblyInfo.cs000644 001750 001750 00000004424 11520622622 034013 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Db4objects.Db4o.CFCompatibilityTests.Device_2008")] [assembly: AssemblyDescription("Device 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("b1163e6d-960b-4f83-a633-b693e4e77f84")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // [assembly: AssemblyVersion("8.0.184.15484")] // Below attribute is to suppress FxCop warning "CA2232 : Microsoft.Usage : Add STAThreadAttribute to assembly" // as Device app does not support STA thread. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2232:MarkWindowsFormsEntryPointsWithStaThread")] Db4objects.Db4o.CFCompatibilityTests/Device/Db4objects.Db4o.CFCompatibilityTests.Device-2008.csproj000644 001750 001750 00000011474 11520622064 040506 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src Debug AnyCPU 9.0.30729 2.0 {67F731E8-692E-4F4C-AF97-E50A5A117A84} WinExe Properties Db4objects.Db4o.CFCompatibilityTests.Device Db4objects.Db4o.CFCompatibilityTests.Device {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 Db4objects.Db4o.CFCompatibilityTests.Device_2008 v3.5 Pocket PC 2003 true full false bin\Debug\ DEBUG;TRACE;$(PlatformFamilyName) true true prompt 512 4 Off pdbonly true bin\Release\ TRACE;$(PlatformFamilyName) true true prompt 512 4 Off Form Console.cs Console.cs ResXFileCodeGenerator Resources.Designer.cs Designer True Resources.resx True {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7} Db4oUnit-CF-2008 {7F388726-A3A0-4CF7-89F4-52926EA02D55} Tests.Subject-CF-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/000755 001750 001750 00000000000 11520622066 024253 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/000755 001750 001750 00000000000 11520622066 031610 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/000755 001750 001750 00000000000 11520622070 034212 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgDb4objects.Db4o.NativeQueries/Optimization/ComparisonQueryGeneratingVisitor.cs000644 001750 001750 00000012615 11520622624 043277 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.Internal; using Db4objects.Db4o.NativeQueries.Expr.Cmp; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; using Db4objects.Db4o.NativeQueries.Optimization; using Sharpen.Lang.Reflect; namespace Db4objects.Db4o.NativeQueries.Optimization { internal sealed class ComparisonQueryGeneratingVisitor : IComparisonOperandVisitor { private object _predicate; private object _value = null; private readonly INativeClassFactory _classSource; private readonly IReferenceResolver _resolver; public object Value() { return _value; } public void Visit(ConstValue operand) { _value = operand.Value(); } public void Visit(FieldValue operand) { operand.Parent().Accept(this); Type clazz = ((operand.Parent() is StaticFieldRoot) ? (Type)_value : _value.GetType ()); try { FieldInfo field = Reflection4.GetField(clazz, operand.FieldName()); _value = field.GetValue(_value); } catch (Exception exc) { // arg is ignored for static Sharpen.Runtime.PrintStackTrace(exc); } } internal object Add(object a, object b) { if (a is double || b is double) { return ((double)a) + ((double)b); } if (a is float || b is float) { return ((float)a) + ((float)b); } if (a is long || b is long) { return ((long)a) + ((long)b); } return ((int)a) + ((int)b); } internal object Subtract(object a, object b) { if (a is double || b is double) { return ((double)a) - ((double)b); } if (a is float || b is float) { return ((float)a) - ((float)b); } if (a is long || b is long) { return ((long)a) - ((long)b); } return ((int)a) - ((int)b); } internal object Multiply(object a, object b) { if (a is double || b is double) { return ((double)a) * ((double)b); } if (a is float || b is float) { return ((float)a) * ((float)b); } if (a is long || b is long) { return ((long)a) * ((long)b); } return ((int)a) * ((int)b); } internal object Divide(object a, object b) { if (a is double || b is double) { return ((double)a) / ((double)b); } if (a is float || b is float) { return ((float)a) / ((float)b); } if (a is long || b is long) { return ((long)a) / ((long)b); } return ((int)a) / ((int)b); } public void Visit(ArithmeticExpression operand) { operand.Left().Accept(this); object left = _value; operand.Right().Accept(this); object right = _value; switch (operand.Op().Id()) { case ArithmeticOperator.AddId: { _value = Add(left, right); break; } case ArithmeticOperator.SubtractId: { _value = Subtract(left, right); break; } case ArithmeticOperator.MultiplyId: { _value = Multiply(left, right); break; } case ArithmeticOperator.DivideId: { _value = Divide(left, right); break; } } } public void Visit(CandidateFieldRoot root) { } public void Visit(PredicateFieldRoot root) { _value = _predicate; } public void Visit(StaticFieldRoot root) { try { _value = _classSource.ForName(root.Type.Name); } catch (TypeLoadException e) { Sharpen.Runtime.PrintStackTrace(e); } } public void Visit(ArrayAccessValue operand) { operand.Parent().Accept(this); object parent = _value; operand.Index().Accept(this); int index = (int)_value; _value = Sharpen.Runtime.GetArrayValue(parent, index); } public void Visit(MethodCallValue operand) { operand.Parent().Accept(this); object receiver = _value; MethodInfo method = _resolver.Resolve(operand.Method); try { _value = method.Invoke(IsStatic(method) ? null : receiver, Args(operand)); } catch (Exception exc) { Sharpen.Runtime.PrintStackTrace(exc); _value = null; } } private object[] Args(MethodCallValue operand) { IComparisonOperand[] args = operand.Args; object[] @params = new object[args.Length]; for (int paramIdx = 0; paramIdx < args.Length; paramIdx++) { args[paramIdx].Accept(this); @params[paramIdx] = _value; } return @params; } private bool IsStatic(MethodInfo method) { return NativeQueriesPlatform.IsStatic(method); } public ComparisonQueryGeneratingVisitor(object predicate, INativeClassFactory classSource , IReferenceResolver resolver) : base() { _predicate = predicate; _classSource = classSource; _resolver = resolver; } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/SODAQueryBuilder.cs000644 001750 001750 00000010625 11520622624 037635 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; using Db4objects.Db4o.NativeQueries.Optimization; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.NativeQueries.Optimization { public class SODAQueryBuilder { private class SODAQueryVisitor : IExpressionVisitor { private object _predicate; private IQuery _query; private IConstraint _constraint; private INativeClassFactory _classSource; private IReferenceResolver _referenceResolver; internal SODAQueryVisitor(IQuery query, object predicate, INativeClassFactory classSource , IReferenceResolver referenceResolver) { _query = query; _predicate = predicate; _classSource = classSource; _referenceResolver = referenceResolver; } public virtual void Visit(AndExpression expression) { expression.Left().Accept(this); IConstraint left = _constraint; expression.Right().Accept(this); left.And(_constraint); _constraint = left; } public virtual void Visit(BoolConstExpression expression) { } public virtual void Visit(OrExpression expression) { expression.Left().Accept(this); IConstraint left = _constraint; expression.Right().Accept(this); left.Or(_constraint); _constraint = left; } public virtual void Visit(ComparisonExpression expression) { IQuery subQuery = Descend(expression.Left()); ComparisonQueryGeneratingVisitor visitor = new ComparisonQueryGeneratingVisitor(_predicate , _classSource, _referenceResolver); expression.Right().Accept(visitor); _constraint = subQuery.Constrain(visitor.Value()); ComparisonOperator op = expression.Op(); if (op.Equals(ComparisonOperator.ValueEquality)) { return; } if (op.Equals(ComparisonOperator.ReferenceEquality)) { _constraint.Identity(); return; } if (op.Equals(ComparisonOperator.Greater)) { _constraint.Greater(); return; } if (op.Equals(ComparisonOperator.Smaller)) { _constraint.Smaller(); return; } if (op.Equals(ComparisonOperator.Contains)) { _constraint.Contains(); return; } if (op.Equals(ComparisonOperator.StartsWith)) { _constraint.StartsWith(true); return; } if (op.Equals(ComparisonOperator.EndsWith)) { _constraint.EndsWith(true); return; } throw new Exception("Can't handle constraint: " + op); } private IQuery Descend(FieldValue left) { IQuery subQuery = _query; IEnumerator fieldNameIterator = FieldNames(left); while (fieldNameIterator.MoveNext()) { subQuery = subQuery.Descend((string)fieldNameIterator.Current); } return subQuery; } public virtual void Visit(NotExpression expression) { expression.Expr().Accept(this); _constraint.Not(); } private IEnumerator FieldNames(FieldValue fieldValue) { Collection4 coll = new Collection4(); IComparisonOperand curOp = fieldValue; while (curOp is FieldValue) { FieldValue curField = (FieldValue)curOp; coll.Prepend(curField.FieldName()); curOp = curField.Parent(); } return coll.GetEnumerator(); } } public virtual void OptimizeQuery(IExpression expr, IQuery query, object predicate , INativeClassFactory classSource, IReferenceResolver referenceResolver) { expr.Accept(new SODAQueryBuilder.SODAQueryVisitor(query, predicate, classSource, referenceResolver)); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/000755 001750 001750 00000000000 11520622070 034727 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgsrc/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/SODAMethodBuilder.cs000644 001750 001750 00000016613 11520622624 040470 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.Internal.Query; using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; using Db4objects.Db4o.NativeQueries.Instrumentation; using Db4objects.Db4o.NativeQueries.Optimization; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.NativeQueries.Instrumentation { public class SODAMethodBuilder { private const bool LogBytecode = false; private IMethodRef descendRef; private IMethodRef constrainRef; private IMethodRef greaterRef; private IMethodRef smallerRef; private IMethodRef containsRef; private IMethodRef startsWithRef; private IMethodRef endsWithRef; private IMethodRef notRef; private IMethodRef andRef; private IMethodRef orRef; private IMethodRef identityRef; private readonly ITypeEditor _editor; private IMethodBuilder _builder; public static readonly string OptimizeQueryMethodName = "optimizeQuery"; private class SODAExpressionBuilder : IExpressionVisitor { private ITypeRef predicateClass; public SODAExpressionBuilder(SODAMethodBuilder _enclosing, ITypeRef predicateClass ) { this._enclosing = _enclosing; this.predicateClass = predicateClass; } public virtual void Visit(AndExpression expression) { expression.Left().Accept(this); expression.Right().Accept(this); this._enclosing.Invoke(this._enclosing.andRef); } public virtual void Visit(BoolConstExpression expression) { this.LoadQuery(); } //throw new RuntimeException("No boolean constants expected in parsed expression tree"); private void LoadQuery() { this._enclosing.LoadArgument(1); } public virtual void Visit(OrExpression expression) { expression.Left().Accept(this); expression.Right().Accept(this); this._enclosing.Invoke(this._enclosing.orRef); } public virtual void Visit(ComparisonExpression expression) { this.LoadQuery(); this.Descend(this.FieldNames(expression.Left())); expression.Right().Accept(this.ComparisonEmitter()); this.Constrain(expression.Op()); } private void Descend(IEnumerator fieldNames) { while (fieldNames.MoveNext()) { this.Descend(fieldNames.Current); } } private ComparisonBytecodeGeneratingVisitor ComparisonEmitter() { return new ComparisonBytecodeGeneratingVisitor(this._enclosing._builder, this.predicateClass ); } private void Constrain(ComparisonOperator op) { this._enclosing.Invoke(this._enclosing.constrainRef); if (op.Equals(ComparisonOperator.ValueEquality)) { return; } if (op.Equals(ComparisonOperator.ReferenceEquality)) { this._enclosing.Invoke(this._enclosing.identityRef); return; } if (op.Equals(ComparisonOperator.Greater)) { this._enclosing.Invoke(this._enclosing.greaterRef); return; } if (op.Equals(ComparisonOperator.Smaller)) { this._enclosing.Invoke(this._enclosing.smallerRef); return; } if (op.Equals(ComparisonOperator.Contains)) { this._enclosing.Invoke(this._enclosing.containsRef); return; } if (op.Equals(ComparisonOperator.StartsWith)) { this._enclosing.Ldc(1); this._enclosing.Invoke(this._enclosing.startsWithRef); return; } if (op.Equals(ComparisonOperator.EndsWith)) { this._enclosing.Ldc(1); this._enclosing.Invoke(this._enclosing.endsWithRef); return; } throw new Exception("Cannot interpret constraint: " + op); } private void Descend(object fieldName) { this._enclosing.Ldc(fieldName); this._enclosing.Invoke(this._enclosing.descendRef); } public virtual void Visit(NotExpression expression) { expression.Expr().Accept(this); this._enclosing.Invoke(this._enclosing.notRef); } private IEnumerator FieldNames(FieldValue fieldValue) { Collection4 coll = new Collection4(); IComparisonOperand curOp = fieldValue; while (curOp is FieldValue) { FieldValue curField = (FieldValue)curOp; coll.Prepend(curField.FieldName()); curOp = curField.Parent(); } return coll.GetEnumerator(); } private readonly SODAMethodBuilder _enclosing; } public SODAMethodBuilder(ITypeEditor editor) { _editor = editor; BuildMethodReferences(); } public virtual void InjectOptimization(IExpression expr) { _editor.AddInterface(TypeRef(typeof(IDb4oEnhancedFilter))); _builder = _editor.NewPublicMethod(PlatformName(OptimizeQueryMethodName), TypeRef (typeof(void)), new ITypeRef[] { TypeRef(typeof(IQuery)) }); ITypeRef predicateClass = _editor.Type; expr.Accept(new SODAMethodBuilder.SODAExpressionBuilder(this, predicateClass)); _builder.Pop(); _builder.EndMethod(); } private ITypeRef TypeRef(Type type) { return _editor.References.ForType(type); } private string PlatformName(string name) { return NativeQueriesPlatform.ToPlatformName(name); } private void LoadArgument(int index) { _builder.LoadArgument(index); } private void Invoke(IMethodRef method) { _builder.Invoke(method, CallingConvention.Interface); } private void Ldc(object value) { _builder.Ldc(value); } private void BuildMethodReferences() { descendRef = MethodRef(typeof(IQuery), "descend", new Type[] { typeof(string) }); constrainRef = MethodRef(typeof(IQuery), "constrain", new Type[] { typeof(object) }); greaterRef = MethodRef(typeof(IConstraint), "greater", new Type[] { }); smallerRef = MethodRef(typeof(IConstraint), "smaller", new Type[] { }); containsRef = MethodRef(typeof(IConstraint), "contains", new Type[] { }); startsWithRef = MethodRef(typeof(IConstraint), "startsWith", new Type[] { typeof( bool) }); endsWithRef = MethodRef(typeof(IConstraint), "endsWith", new Type[] { typeof(bool ) }); notRef = MethodRef(typeof(IConstraint), "not", new Type[] { }); andRef = MethodRef(typeof(IConstraint), "and", new Type[] { typeof(IConstraint) } ); orRef = MethodRef(typeof(IConstraint), "or", new Type[] { typeof(IConstraint) }); identityRef = MethodRef(typeof(IConstraint), "identity", new Type[] { }); } private IMethodRef MethodRef(Type parent, string name, Type[] args) { try { return _editor.References.ForMethod(parent.GetMethod(PlatformName(name), args)); } catch (Exception e) { throw new InstrumentationException(e); } } } } Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/TypeDeducingVisitor.cs000644 001750 001750 00000004111 11520622624 041224 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Instrumentation { internal class TypeDeducingVisitor : IComparisonOperandVisitor { private ITypeRef _predicateClass; private ITypeRef _clazz; private IReferenceProvider _referenceProvider; public TypeDeducingVisitor(IReferenceProvider provider, ITypeRef predicateClass) { this._predicateClass = predicateClass; this._referenceProvider = provider; _clazz = null; } public virtual void Visit(PredicateFieldRoot root) { _clazz = _predicateClass; } public virtual void Visit(CandidateFieldRoot root) { } // _clazz=_candidateClass; public virtual void Visit(StaticFieldRoot root) { _clazz = root.Type; } public virtual ITypeRef OperandClass() { return _clazz; } public virtual void Visit(ArithmeticExpression operand) { } public virtual void Visit(ConstValue operand) { _clazz = _referenceProvider.ForType(operand.Value().GetType()); } public virtual void Visit(FieldValue operand) { _clazz = operand.Field.Type; } public virtual void Visit(ArrayAccessValue operand) { operand.Parent().Accept(this); _clazz = _clazz.ElementType; } public virtual void Visit(MethodCallValue operand) { _clazz = operand.Method.ReturnType; } } } Db4objects.Db4o.NativeQueries/Instrumentation/ComparisonBytecodeGeneratingVisitor.cs000644 001750 001750 00000014640 11520622624 044445 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; using Db4objects.Db4o.NativeQueries.Instrumentation; namespace Db4objects.Db4o.NativeQueries.Instrumentation { internal class ComparisonBytecodeGeneratingVisitor : IComparisonOperandVisitor { private IMethodBuilder _methodBuilder; private ITypeRef _predicateClass; private bool _inArithmetic = false; private ITypeRef _opClass = null; private ITypeRef _staticRoot = null; public ComparisonBytecodeGeneratingVisitor(IMethodBuilder methodBuilder, ITypeRef predicateClass) { this._methodBuilder = methodBuilder; this._predicateClass = predicateClass; } public virtual void Visit(ConstValue operand) { object value = operand.Value(); if (value != null) { _opClass = TypeRef(value.GetType()); } _methodBuilder.Ldc(value); if (value != null) { Box(_opClass, !_inArithmetic); } } private ITypeRef TypeRef(Type type) { return _methodBuilder.References.ForType(type); } public virtual void Visit(FieldValue fieldValue) { ITypeRef lastFieldClass = fieldValue.Field.Type; bool needConversion = lastFieldClass.IsPrimitive; fieldValue.Parent().Accept(this); if (_staticRoot != null) { _methodBuilder.LoadStaticField(fieldValue.Field); _staticRoot = null; return; } _methodBuilder.LoadField(fieldValue.Field); Box(lastFieldClass, !_inArithmetic && needConversion); } public virtual void Visit(CandidateFieldRoot root) { _methodBuilder.LoadArgument(1); } public virtual void Visit(PredicateFieldRoot root) { _methodBuilder.LoadArgument(0); } public virtual void Visit(StaticFieldRoot root) { _staticRoot = root.Type; } public virtual void Visit(ArrayAccessValue operand) { ITypeRef cmpType = DeduceFieldClass(operand.Parent()).ElementType; operand.Parent().Accept(this); bool outerInArithmetic = _inArithmetic; _inArithmetic = true; operand.Index().Accept(this); _inArithmetic = outerInArithmetic; _methodBuilder.LoadArrayElement(cmpType); Box(cmpType, !_inArithmetic); } public virtual void Visit(MethodCallValue operand) { IMethodRef method = operand.Method; ITypeRef retType = method.ReturnType; // FIXME: this should be handled within conversions bool needConversion = retType.IsPrimitive; operand.Parent().Accept(this); bool oldInArithmetic = _inArithmetic; for (int paramIdx = 0; paramIdx < operand.Args.Length; paramIdx++) { _inArithmetic = operand.Method.ParamTypes[paramIdx].IsPrimitive; operand.Args[paramIdx].Accept(this); } _inArithmetic = oldInArithmetic; _methodBuilder.Invoke(method, operand.CallingConvention); Box(retType, !_inArithmetic && needConversion); } public virtual void Visit(ArithmeticExpression operand) { bool oldInArithmetic = _inArithmetic; _inArithmetic = true; operand.Left().Accept(this); operand.Right().Accept(this); ITypeRef operandType = ArithmeticType(operand); switch (operand.Op().Id()) { case ArithmeticOperator.AddId: { _methodBuilder.Add(operandType); break; } case ArithmeticOperator.SubtractId: { _methodBuilder.Subtract(operandType); break; } case ArithmeticOperator.MultiplyId: { _methodBuilder.Multiply(operandType); break; } case ArithmeticOperator.DivideId: { _methodBuilder.Divide(operandType); break; } default: { throw new Exception("Unknown operand: " + operand.Op()); } } Box(_opClass, !oldInArithmetic); _inArithmetic = oldInArithmetic; } // FIXME: need to map dX,fX,... private void Box(ITypeRef boxedType, bool canApply) { if (!canApply) { return; } _methodBuilder.Box(boxedType); } private ITypeRef DeduceFieldClass(IComparisonOperand fieldValue) { TypeDeducingVisitor visitor = new TypeDeducingVisitor(_methodBuilder.References, _predicateClass); fieldValue.Accept(visitor); return visitor.OperandClass(); } private ITypeRef ArithmeticType(IComparisonOperand operand) { if (operand is ConstValue) { return PrimitiveType(((ConstValue)operand).Value().GetType()); } if (operand is FieldValue) { return ((FieldValue)operand).Field.Type; } if (operand is ArithmeticExpression) { ArithmeticExpression expr = (ArithmeticExpression)operand; ITypeRef left = ArithmeticType(expr.Left()); ITypeRef right = ArithmeticType(expr.Right()); if (left == DoubleType() || right == DoubleType()) { return DoubleType(); } if (left == FloatType() || right == FloatType()) { return FloatType(); } if (left == LongType() || right == LongType()) { return LongType(); } return IntType(); } return null; } private ITypeRef PrimitiveType(Type klass) { if (klass == typeof(int) || klass == typeof(short) || klass == typeof(bool) || klass == typeof(byte)) { return IntType(); } if (klass == typeof(double)) { return DoubleType(); } if (klass == typeof(float)) { return FloatType(); } if (klass == typeof(long)) { return LongType(); } return TypeRef(klass); } private ITypeRef IntType() { return TypeRef(typeof(int)); } private ITypeRef LongType() { return TypeRef(typeof(long)); } private ITypeRef FloatType() { return TypeRef(typeof(float)); } private ITypeRef DoubleType() { return TypeRef(typeof(double)); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/000755 001750 001750 00000000000 11520622070 032521 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/ComparisonExpression.cs000644 001750 001750 00000004416 11520622624 037175 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr { public class ComparisonExpression : IExpression { private FieldValue _left; private IComparisonOperand _right; private ComparisonOperator _op; public ComparisonExpression(FieldValue left, IComparisonOperand right, ComparisonOperator op) { if (left == null || right == null || op == null) { throw new ArgumentNullException(); } this._left = left; this._right = right; this._op = op; } public virtual FieldValue Left() { return _left; } public virtual IComparisonOperand Right() { return _right; } public virtual ComparisonOperator Op() { return _op; } public override string ToString() { return _left + " " + _op + " " + _right; } public override bool Equals(object other) { if (this == other) { return true; } if (other == null || GetType() != other.GetType()) { return false; } Db4objects.Db4o.NativeQueries.Expr.ComparisonExpression casted = (Db4objects.Db4o.NativeQueries.Expr.ComparisonExpression )other; return _left.Equals(casted._left) && _right.Equals(casted._right) && _op.Equals(casted ._op); } public override int GetHashCode() { return (_left.GetHashCode() * 29 + _right.GetHashCode()) * 29 + _op.GetHashCode(); } public virtual void Accept(IExpressionVisitor visitor) { visitor.Visit(this); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BinaryExpression.cs000644 001750 001750 00000003407 11520622624 036306 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public abstract class BinaryExpression : IExpression { protected IExpression _left; protected IExpression _right; public BinaryExpression(IExpression left, IExpression right) { this._left = left; this._right = right; } public virtual IExpression Left() { return _left; } public virtual IExpression Right() { return _right; } public override bool Equals(object other) { if (this == other) { return true; } if (other == null || GetType() != other.GetType()) { return false; } Db4objects.Db4o.NativeQueries.Expr.BinaryExpression casted = (Db4objects.Db4o.NativeQueries.Expr.BinaryExpression )other; return _left.Equals(casted._left) && (_right.Equals(casted._right)) || _left.Equals (casted._right) && (_right.Equals(casted._left)); } public override int GetHashCode() { return _left.GetHashCode() + _right.GetHashCode(); } public abstract void Accept(IExpressionVisitor arg1); } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Build/000755 001750 001750 00000000000 11520622042 033557 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Build/ExpressionBuilder.cs000644 001750 001750 00000013034 11520622624 037504 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Build { public class ExpressionBuilder { /// Optimizations: !(Bool)->(!Bool), !!X->X, !(X==Bool)->(X==!Bool) /// public virtual IExpression Not(IExpression expr) { if (expr.Equals(BoolConstExpression.True)) { return BoolConstExpression.False; } if (expr.Equals(BoolConstExpression.False)) { return BoolConstExpression.True; } if (expr is NotExpression) { return ((NotExpression)expr).Expr(); } if (expr is ComparisonExpression) { ComparisonExpression cmpExpr = (ComparisonExpression)expr; if (cmpExpr.Right() is ConstValue) { ConstValue rightConst = (ConstValue)cmpExpr.Right(); if (rightConst.Value() is bool) { bool boolVal = (bool)rightConst.Value(); // new Boolean() instead of Boolean.valueOf() for .NET conversion return new ComparisonExpression(cmpExpr.Left(), new ConstValue(!boolVal), cmpExpr .Op()); } } } return new NotExpression(expr); } /// Optimizations: f&&X->f, t&&X->X, X&&X->X, X&&!X->f public virtual IExpression And(IExpression left, IExpression right) { if (left.Equals(BoolConstExpression.False) || right.Equals(BoolConstExpression.False )) { return BoolConstExpression.False; } if (left.Equals(BoolConstExpression.True)) { return right; } if (right.Equals(BoolConstExpression.True)) { return left; } if (left.Equals(right)) { return left; } if (Negatives(left, right)) { return BoolConstExpression.False; } return new AndExpression(left, right); } /// Optimizations: X||t->t, f||X->X, X||X->X, X||!X->t public virtual IExpression Or(IExpression left, IExpression right) { if (left.Equals(BoolConstExpression.True) || right.Equals(BoolConstExpression.True )) { return BoolConstExpression.True; } if (left.Equals(BoolConstExpression.False)) { return right; } if (right.Equals(BoolConstExpression.False)) { return left; } if (left.Equals(right)) { return left; } if (Negatives(left, right)) { return BoolConstExpression.True; } return new OrExpression(left, right); } /// Optimizations: static bool roots public virtual BoolConstExpression Constant(bool value) { return BoolConstExpression.Expr(value); } public virtual IExpression IfThenElse(IExpression cond, IExpression truePath, IExpression falsePath) { IExpression expr = CheckBoolean(cond, truePath, falsePath); if (expr != null) { return expr; } return Or(And(cond, truePath), And(Not(cond), falsePath)); } private IExpression CheckBoolean(IExpression cmp, IExpression trueExpr, IExpression falseExpr) { if (cmp is BoolConstExpression) { return null; } if (trueExpr is BoolConstExpression) { bool leftNegative = trueExpr.Equals(BoolConstExpression.False); if (!leftNegative) { return Or(cmp, falseExpr); } else { return And(Not(cmp), falseExpr); } } if (falseExpr is BoolConstExpression) { bool rightNegative = falseExpr.Equals(BoolConstExpression.False); if (!rightNegative) { return And(cmp, trueExpr); } else { return Or(Not(cmp), falseExpr); } } if (cmp is NotExpression) { cmp = ((NotExpression)cmp).Expr(); IExpression swap = trueExpr; trueExpr = falseExpr; falseExpr = swap; } if (trueExpr is OrExpression) { OrExpression orExpr = (OrExpression)trueExpr; IExpression orLeft = orExpr.Left(); IExpression orRight = orExpr.Right(); if (falseExpr.Equals(orRight)) { IExpression swap = orRight; orRight = orLeft; orLeft = swap; } if (falseExpr.Equals(orLeft)) { return Or(orLeft, And(cmp, orRight)); } } if (falseExpr is AndExpression) { AndExpression andExpr = (AndExpression)falseExpr; IExpression andLeft = andExpr.Left(); IExpression andRight = andExpr.Right(); if (trueExpr.Equals(andRight)) { IExpression swap = andRight; andRight = andLeft; andLeft = swap; } if (trueExpr.Equals(andLeft)) { return And(andLeft, Or(cmp, andRight)); } } return null; } private bool Negatives(IExpression left, IExpression right) { return NegativeOf(left, right) || NegativeOf(right, left); } private bool NegativeOf(IExpression right, IExpression left) { return (right is NotExpression) && ((NotExpression)right).Expr().Equals(left); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionVisitor.cs000644 001750 001750 00000002027 11520622624 036627 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public interface IExpressionVisitor { void Visit(AndExpression expression); void Visit(OrExpression expression); void Visit(NotExpression expression); void Visit(ComparisonExpression expression); void Visit(BoolConstExpression expression); } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/NotExpression.cs000644 001750 001750 00000003122 11520622624 035614 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public class NotExpression : IExpression { private IExpression _expr; public NotExpression(IExpression expr) { this._expr = expr; } public override string ToString() { return "!(" + _expr + ")"; } public virtual IExpression Expr() { return _expr; } public override bool Equals(object other) { if (this == other) { return true; } if (other == null || GetType() != other.GetType()) { return false; } Db4objects.Db4o.NativeQueries.Expr.NotExpression casted = (Db4objects.Db4o.NativeQueries.Expr.NotExpression )other; return _expr.Equals(casted._expr); } public override int GetHashCode() { return -_expr.GetHashCode(); } public virtual void Accept(IExpressionVisitor visitor) { visitor.Visit(this); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpression.cs000644 001750 001750 00000002002 11520622624 035240 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public interface IExpression : IExpressionPart { /// /// must implement the visitor interface required /// by the concrete Expression implementation. /// void Accept(IExpressionVisitor visitor); } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionPart.cs000644 001750 001750 00000001406 11520622624 036076 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.NativeQueries.Expr { public interface IExpressionPart { } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/TraversingExpressionVisitor.cs000644 001750 001750 00000004647 11520622624 040575 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr { public class TraversingExpressionVisitor : IExpressionVisitor, IComparisonOperandVisitor { public virtual void Visit(AndExpression expression) { expression.Left().Accept(this); expression.Right().Accept(this); } public virtual void Visit(BoolConstExpression expression) { } public virtual void Visit(OrExpression expression) { expression.Left().Accept(this); expression.Right().Accept(this); } public virtual void Visit(ComparisonExpression expression) { expression.Left().Accept(this); expression.Right().Accept(this); } public virtual void Visit(NotExpression expression) { expression.Expr().Accept(this); } public virtual void Visit(ArithmeticExpression operand) { operand.Left().Accept(this); operand.Right().Accept(this); } public virtual void Visit(ConstValue operand) { } public virtual void Visit(FieldValue operand) { operand.Parent().Accept(this); } public virtual void Visit(CandidateFieldRoot root) { } public virtual void Visit(PredicateFieldRoot root) { } public virtual void Visit(StaticFieldRoot root) { } public virtual void Visit(ArrayAccessValue operand) { operand.Parent().Accept(this); operand.Index().Accept(this); } public virtual void Visit(MethodCallValue value) { value.Parent().Accept(this); VisitArgs(value); } protected virtual void VisitArgs(MethodCallValue value) { IComparisonOperand[] args = value.Args; for (int i = 0; i < args.Length; ++i) { args[i].Accept(this); } } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/OrExpression.cs000644 001750 001750 00000002132 11520622624 035434 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public class OrExpression : BinaryExpression { public OrExpression(IExpression left, IExpression right) : base(left, right) { } public override string ToString() { return "(" + _left + ")||(" + _right + ")"; } public override void Accept(IExpressionVisitor visitor) { visitor.Visit(this); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IgnoredExpression.cs000644 001750 001750 00000002101 11520622624 036437 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public sealed class IgnoredExpression : IExpression { public static Db4objects.Db4o.NativeQueries.Expr.IgnoredExpression Instance = new Db4objects.Db4o.NativeQueries.Expr.IgnoredExpression(); private IgnoredExpression() { } public void Accept(IExpressionVisitor visitor) { } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/000755 001750 001750 00000000000 11520622060 033237 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ArithmeticOperator.cs000644 001750 001750 00000003560 11520622624 037326 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.NativeQueries.Expr.Cmp { public sealed class ArithmeticOperator { public const int AddId = 0; public const int SubtractId = 1; public const int MultiplyId = 2; public const int DivideId = 3; public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator Add = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(AddId, "+"); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator Subtract = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(SubtractId , "-"); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator Multiply = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(MultiplyId , "*"); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator Divide = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(DivideId, "/"); private string _op; private int _id; private ArithmeticOperator(int id, string op) { _id = id; _op = op; } public int Id() { return _id; } public override string ToString() { return _op; } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/000755 001750 001750 00000000000 11520622070 034551 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgDb4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArithmeticExpression.cs000644 001750 001750 00000004314 11520622624 041260 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class ArithmeticExpression : IComparisonOperand { private ArithmeticOperator _op; private IComparisonOperand _left; private IComparisonOperand _right; public ArithmeticExpression(IComparisonOperand left, IComparisonOperand right, ArithmeticOperator op) { this._op = op; this._left = left; this._right = right; } public virtual IComparisonOperand Left() { return _left; } public virtual IComparisonOperand Right() { return _right; } public virtual ArithmeticOperator Op() { return _op; } public override string ToString() { return "(" + _left + _op + _right + ")"; } public override bool Equals(object obj) { if (this == obj) { return true; } if (obj == null || obj.GetType() != GetType()) { return false; } Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArithmeticExpression casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArithmeticExpression )obj; return _left.Equals(casted._left) && _right.Equals(casted._right) && _op.Equals(casted ._op); } public override int GetHashCode() { int hc = _left.GetHashCode(); hc *= 29 + _right.GetHashCode(); hc *= 29 + _op.GetHashCode(); return hc; } public virtual void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/StaticFieldRoot.cs000644 001750 001750 00000003431 11520622624 040145 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class StaticFieldRoot : ComparisonOperandRoot { private ITypeRef _type; public StaticFieldRoot(ITypeRef type) { if (null == type) { throw new ArgumentNullException(); } _type = type; } public virtual ITypeRef Type { get { return _type; } } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj == null || GetType() != obj.GetType()) { return false; } Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.StaticFieldRoot casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.StaticFieldRoot )obj; return _type.Equals(casted._type); } public override int GetHashCode() { return _type.GetHashCode(); } public override string ToString() { return _type.ToString(); } public override void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } } } Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandAnchor.cs000644 001750 001750 00000001665 11520622624 042004 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public interface IComparisonOperandAnchor : IComparisonOperand { IComparisonOperandAnchor Parent(); IComparisonOperandAnchor Root(); } } Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandRoot.cs000644 001750 001750 00000002111 11520622624 041367 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public abstract class ComparisonOperandRoot : IComparisonOperandAnchor { public virtual IComparisonOperandAnchor Parent() { return null; } public IComparisonOperandAnchor Root() { return this; } public abstract void Accept(IComparisonOperandVisitor arg1); } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArrayAccessValue.cs000644 001750 001750 00000003600 11520622624 040301 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class ArrayAccessValue : ComparisonOperandDescendant { private IComparisonOperand _index; public ArrayAccessValue(ComparisonOperandDescendant parent, IComparisonOperand index ) : base(parent) { _index = index; } public override void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } public virtual IComparisonOperand Index() { return _index; } public override bool Equals(object obj) { if (!base.Equals(obj)) { return false; } Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArrayAccessValue casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArrayAccessValue )obj; return _index.Equals(casted._index); } public override int GetHashCode() { return base.GetHashCode() * 29 + _index.GetHashCode(); } public override string ToString() { return base.ToString() + "[" + _index + "]"; } public override ITypeRef Type { get { return ((ComparisonOperandDescendant)Parent()).Type.ElementType; } } } } Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperand.cs000644 001750 001750 00000001676 11520622624 040653 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public interface IComparisonOperand : IExpressionPart { void Accept(IComparisonOperandVisitor visitor); } } Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/PredicateFieldRoot.cs000644 001750 001750 00000002370 11520622624 040617 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class PredicateFieldRoot : ComparisonOperandRoot { public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.PredicateFieldRoot Instance = new Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.PredicateFieldRoot (); private PredicateFieldRoot() { } public override string ToString() { return "PREDICATE"; } public override void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } } } Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandVisitor.cs000644 001750 001750 00000002232 11520622624 042220 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public interface IComparisonOperandVisitor { void Visit(ArithmeticExpression operand); void Visit(ConstValue operand); void Visit(FieldValue operand); void Visit(CandidateFieldRoot root); void Visit(PredicateFieldRoot root); void Visit(StaticFieldRoot root); void Visit(ArrayAccessValue operand); void Visit(MethodCallValue value); } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/MethodCallValue.cs000644 001750 001750 00000005230 11520622624 040116 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class MethodCallValue : ComparisonOperandDescendant { private readonly IMethodRef _method; private readonly IComparisonOperand[] _args; private readonly Db4objects.Db4o.Instrumentation.Api.CallingConvention _callingConvention; public MethodCallValue(IMethodRef method, Db4objects.Db4o.Instrumentation.Api.CallingConvention callingConvention, IComparisonOperandAnchor parent, IComparisonOperand[] args) : base(parent) { _method = method; _args = args; _callingConvention = callingConvention; } public override void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } public virtual IComparisonOperand[] Args { get { return _args; } } public override bool Equals(object obj) { if (!base.Equals(obj)) { return false; } Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.MethodCallValue casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.MethodCallValue )obj; return _method.Equals(casted._method) && _callingConvention == casted._callingConvention; } public override int GetHashCode() { int hc = base.GetHashCode(); hc *= 29 + _method.GetHashCode(); hc *= 29 + _args.GetHashCode(); hc *= 29 + _callingConvention.GetHashCode(); return hc; } public override string ToString() { return base.ToString() + "." + _method.Name + Iterators.Join(Iterators.Iterate(_args ), "(", ")", ", "); } public virtual IMethodRef Method { get { return _method; } } public virtual Db4objects.Db4o.Instrumentation.Api.CallingConvention CallingConvention { get { return _callingConvention; } } public override ITypeRef Type { get { return _method.ReturnType; } } } } Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/CandidateFieldRoot.cs000644 001750 001750 00000002370 11520622624 040573 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class CandidateFieldRoot : ComparisonOperandRoot { public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.CandidateFieldRoot Instance = new Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.CandidateFieldRoot (); private CandidateFieldRoot() { } public override string ToString() { return "CANDIDATE"; } public override void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } } } Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandDescendant.cs000644 001750 001750 00000003621 11520622624 042523 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public abstract class ComparisonOperandDescendant : IComparisonOperandAnchor { private IComparisonOperandAnchor _parent; protected ComparisonOperandDescendant(IComparisonOperandAnchor _parent) { this._parent = _parent; } public IComparisonOperandAnchor Parent() { return _parent; } public IComparisonOperandAnchor Root() { return _parent.Root(); } public abstract ITypeRef Type { get; } public override bool Equals(object obj) { if (this == obj) { return true; } if (obj == null || GetType() != obj.GetType()) { return false; } Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ComparisonOperandDescendant casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ComparisonOperandDescendant)obj; return _parent.Equals(casted._parent); } public override int GetHashCode() { return _parent.GetHashCode(); } public override string ToString() { return _parent.ToString(); } public abstract void Accept(IComparisonOperandVisitor arg1); } } Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ThreeWayComparison.cs000644 001750 001750 00000002547 11520622624 040700 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class ThreeWayComparison : IExpressionPart { private FieldValue _left; private IComparisonOperand _right; private bool _swapped; public ThreeWayComparison(FieldValue left, IComparisonOperand right, bool swapped ) { this._left = left; this._right = right; _swapped = swapped; } public virtual FieldValue Left() { return _left; } public virtual IComparisonOperand Right() { return _right; } public virtual bool Swapped() { return _swapped; } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/FieldValue.cs000644 001750 001750 00000003571 11520622624 037133 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class FieldValue : ComparisonOperandDescendant { private readonly IFieldRef _field; public FieldValue(IComparisonOperandAnchor root, IFieldRef field) : base(root) { _field = field; } public virtual string FieldName() { return _field.Name; } public override bool Equals(object other) { if (!base.Equals(other)) { return false; } Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.FieldValue casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.FieldValue )other; return _field.Equals(casted._field); } public override int GetHashCode() { return base.GetHashCode() * 29 + _field.GetHashCode(); } public override string ToString() { return base.ToString() + "." + _field; } public override void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } public virtual IFieldRef Field { get { return _field; } } public override ITypeRef Type { get { return _field.Type; } } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ConstValue.cs000644 001750 001750 00000003647 11520622624 037202 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand { public class ConstValue : IComparisonOperand { private object _value; public ConstValue(object value) { this._value = value; } public virtual object Value() { return _value; } public virtual void Value(object value) { _value = value; } public override string ToString() { if (_value == null) { return "null"; } if (_value is string) { return "\"" + _value + "\""; } return _value.ToString(); } public override bool Equals(object other) { if (this == other) { return true; } if (other == null || GetType() != other.GetType()) { return false; } object otherValue = ((Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ConstValue)other )._value; if (otherValue == _value) { return true; } if (otherValue == null || _value == null) { return false; } return _value.Equals(otherValue); } public override int GetHashCode() { return _value.GetHashCode(); } public virtual void Accept(IComparisonOperandVisitor visitor) { visitor.Visit(this); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ComparisonOperator.cs000644 001750 001750 00000005520 11520622624 037345 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.NativeQueries.Expr.Cmp { public sealed class ComparisonOperator { public const int EqualsId = 0; public const int SmallerId = 1; public const int GreaterId = 2; public const int ContainsId = 3; public const int StartswithId = 4; public const int EndswithId = 5; public const int IdentityId = 6; public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator ValueEquality = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(EqualsId , "==", true); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator Smaller = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(SmallerId , "<", false); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator Greater = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(GreaterId , ">", false); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator Contains = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(ContainsId , "", false); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator StartsWith = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(StartswithId , "", false); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator EndsWith = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(EndswithId , "", false); public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator ReferenceEquality = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator (IdentityId, "===", true); private int _id; private string _op; private bool _symmetric; private ComparisonOperator(int id, string op, bool symmetric) { // TODO: switch to individual classes and visitor dispatch? _id = id; _op = op; _symmetric = symmetric; } public int Id() { return _id; } public override string ToString() { return _op; } public bool IsSymmetric() { return _symmetric; } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BoolConstExpression.cs000644 001750 001750 00000003275 11520622624 036767 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public class BoolConstExpression : IExpression { public static readonly Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression True = new Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression(true); public static readonly Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression False = new Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression(false); private bool _value; private BoolConstExpression(bool value) { this._value = value; } public virtual bool Value() { return _value; } public override string ToString() { return _value.ToString(); } public static Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression Expr(bool value ) { return (value ? True : False); } public virtual void Accept(IExpressionVisitor visitor) { visitor.Visit(this); } public virtual IExpression Negate() { return (_value ? False : True); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/AndExpression.cs000644 001750 001750 00000002134 11520622624 035560 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.NativeQueries.Expr; namespace Db4objects.Db4o.NativeQueries.Expr { public class AndExpression : BinaryExpression { public AndExpression(IExpression left, IExpression right) : base(left, right) { } public override string ToString() { return "(" + _left + ")&&(" + _right + ")"; } public override void Accept(IExpressionVisitor visitor) { visitor.Visit(this); } } } src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-CF-2008.csproj000644 001750 001750 00000020232 11520622066 033627 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg Debug AnyCPU 9.0.30729 2.0 {84DA1E13-9FBB-4A5D-B657-04973B40B48C} Library Properties Db4objects.Db4o.NativeQueries_CF_2008 Db4objects.Db4o.NativeQueries {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 Db4objects.Db4o.NativeQueries_CF_2008 v3.5 2.0 Pocket PC 2003 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;CF_3_5;CF;$(PlatformFamilyName) prompt 512 4 true true Off bin\Debug\Db4objects.Db4o.NativeQueries.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;CF_3_5;CF;$(PlatformFamilyName) prompt 512 4 true true Off bin\Release\Db4objects.Db4o.NativeQueries.xml 1591;1572;1573;1574;0419; False ..\Libs\compact-2.0\Cecil.FlowAnalysis.dll False ..\Libs\compact-2.0\Mono.Cecil.dll {F266671C-596C-486B-B9E2-CE456FBC40D7} Db4objects.Db4o.Instrumentation-CF-2008 {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/native/000755 001750 001750 00000000000 11520622042 025533 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/000755 001750 001750 00000000000 11520622066 033076 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/Optimization/000755 001750 001750 00000000000 11520622042 035477 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgnative/Db4objects.Db4o.NativeQueries/Optimization/NativeQueriesPlatform.cs000644 001750 001750 00000001763 11520622624 042334 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; namespace Db4objects.Db4o.NativeQueries.Optimization { class NativeQueriesPlatform { public static bool IsStatic(MethodInfo method) { return method.IsStatic; } public static string ToPlatformName(string name) { return char.ToUpper(name[0]) + name.Substring(1); } } } src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/ICachingStrategy.cs000644 001750 001750 00000001454 11520622624 036542 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Internal.Query { public interface ICachingStrategy { void Add(K key, V item); V Get(K key); } }src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/NQOptimizer.cs000644 001750 001750 00000003042 11520622624 035566 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using Db4objects.Db4o.Instrumentation.Api; using Db4objects.Db4o.Instrumentation.Cecil; using Db4objects.Db4o.Instrumentation.Core; using Db4objects.Db4o.Internal.Query; using Db4objects.Db4o.NativeQueries.Expr; using Db4objects.Db4o.NativeQueries.Optimization; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.NativeQueries { public class NQOptimizer : INQOptimizer { private readonly INativeClassFactory _classFactory = new DefaultNativeClassFactory(); public void Optimize(IQuery q, object predicate, MethodBase filterMethod) { // TODO: cache predicate expressions here QueryExpressionBuilder builder = new QueryExpressionBuilder(); IExpression expression = builder.FromMethod(filterMethod); new SODAQueryBuilder().OptimizeQuery(expression, q, predicate, _classFactory, new CecilReferenceResolver()); } } } src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/QueryExpressionBuilder.cs000644 001750 001750 00000066670 11520622624 040061 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections.Generic; using Db4objects.Db4o.Activation; using Db4objects.Db4o.Instrumentation.Cecil; using Db4objects.Db4o.TA; using Mono.Collections.Generic; namespace Db4objects.Db4o.NativeQueries { using System; using System.Collections; using System.Reflection; using Mono.Cecil; using Cecil.FlowAnalysis; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.CodeStructure; using Ast = Cecil.FlowAnalysis.CodeStructure; using Expr; using Expr.Cmp; using Expr.Cmp.Operand; using NQExpression = Expr.IExpression; using Internal.Query; /// /// Build a Db4objects.Db4o.Nativequery.Expr tree out of a predicate method definition. /// public class QueryExpressionBuilder { protected static ICachingStrategy _assemblyCachingStrategy = new SingleItemCachingStrategy( delegate(string location) { return AssemblyDefinition.ReadAssembly(location); }); protected static ICachingStrategy _expressionCachingStrategy = new SingleItemCachingStrategy( delegate(MethodBase method) { MethodDefinition methodDef = GetMethodDefinition(method); return AdjustBoxedValueTypes(FromMethodDefinition(methodDef)); } ); public NQExpression FromMethod(MethodBase method) { if (method == null) throw new ArgumentNullException("method"); return GetCachedExpression(method); } private static NQExpression GetCachedExpression(MethodBase method) { return _expressionCachingStrategy.Get(method); } private static MethodDefinition GetMethodDefinition(MethodBase method) { string location = GetAssemblyLocation(method); #if CF MethodDefinition methodDef = MethodDefinitionFor(method); #else AssemblyDefinition assembly = _assemblyCachingStrategy.Get(location); MethodDefinition methodDef = (MethodDefinition)assembly.MainModule.LookupToken(method.MetadataToken); #endif if (null == methodDef) UnsupportedPredicate(string.Format("Unable to load the definition of '{0}' from assembly '{1}'", method, location)); return methodDef; } private static MethodDefinition MethodDefinitionFor(MethodBase method) { string location = GetAssemblyLocation(method); AssemblyDefinition assembly = _assemblyCachingStrategy.Get(location); #if CF TypeDefinition declaringType = FindTypeDefinition(assembly.MainModule, method.DeclaringType); if (declaringType == null) { return null; } foreach (MethodDefinition candidate in declaringType.Methods) { if (candidate.Name != method.Name) continue; if (candidate.Parameters.Count != method.GetParameters().Length) continue; if (!ParametersMatch(candidate.Parameters, GetParameterTypes(method, assembly.MainModule))) continue; { return candidate; } } return null; #else return (MethodDefinition) assembly.MainModule.LookupToken(method.MetadataToken); #endif } private static NQExpression AdjustBoxedValueTypes(NQExpression expression) { expression.Accept(new BoxedValueTypeProcessor()); return expression; } private static IList GetParameterTypes(MethodBase method, ModuleDefinition module) { IList types = new List(); foreach (ParameterInfo parameter in ParametersFor(method)) { types.Add(FindTypeDefinition(module, parameter.ParameterType)); } return types; } private static ParameterInfo[] ParametersFor(MethodBase method) { if (method.IsGenericMethod) { MethodInfo methodInfo = (MethodInfo) method; return methodInfo.GetGenericMethodDefinition().GetParameters(); } return method.DeclaringType.IsGenericType ? method.DeclaringType.GetGenericTypeDefinition().GetMethod(method.Name).GetParameters() : method.GetParameters(); } private static TypeDefinition FindTypeDefinition(ModuleDefinition module, Type type) { return IsNested(type) ? FindNestedTypeDefinition(module, type) : FindTypeDefinition(module, type.IsGenericType ? type.Name : type.FullName); } private static bool IsNested(Type type) { return type.IsNestedPublic || type.IsNestedPrivate || type.IsNestedAssembly; } private static TypeDefinition FindNestedTypeDefinition(ModuleDefinition module, Type type) { foreach (TypeDefinition td in FindTypeDefinition(module, type.DeclaringType).NestedTypes) { if (td.Name == type.Name) return td; } return null; } private static TypeDefinition FindTypeDefinition(ModuleDefinition module, string name) { return module.GetType(name); } private static string GetAssemblyLocation(MethodBase method) { return method.DeclaringType.Module.FullyQualifiedName; } public static NQExpression FromMethodDefinition(MethodDefinition method) { ValidatePredicateMethodDefinition(method); Expression expression = GetQueryExpression(method); if (null == expression) UnsupportedPredicate("No expression found."); Visitor visitor = new Visitor(method, new AssemblyResolver(_assemblyCachingStrategy)); expression.Accept(visitor); return visitor.Expression; } private static void ValidatePredicateMethodDefinition(MethodDefinition method) { if (method == null) throw new ArgumentNullException("method"); if (1 != method.Parameters.Count) UnsupportedPredicate("A predicate must take a single argument."); if (0 != method.Body.ExceptionHandlers.Count) UnsupportedPredicate("A predicate can not contain exception handlers."); if (method.ReturnType.FullName != typeof(bool).FullName) UnsupportedPredicate("A predicate must have a boolean return type."); } private static Expression GetQueryExpression(MethodDefinition method) { ActionFlowGraph afg = FlowGraphFactory.CreateActionFlowGraph(FlowGraphFactory.CreateControlFlowGraph(method)); return GetQueryExpression(afg); } private static void UnsupportedPredicate(string reason) { throw new UnsupportedPredicateException(reason); } private static void UnsupportedExpression(Expression node) { UnsupportedPredicate("Unsupported expression: " + ExpressionPrinter.ToString(node)); } private static Expression GetQueryExpression(ActionFlowGraph afg) { IDictionary variables = new Dictionary(); ActionBlock block = afg.Blocks[0]; while (block != null) { switch (block.ActionType) { case ActionType.Invoke: InvokeActionBlock invokeBlock = (InvokeActionBlock)block; MethodInvocationExpression invocation = invokeBlock.Expression; if (IsActivateInvocation(invocation) || IsNoSideEffectIndirectActivationInvocation(invocation)) { block = invokeBlock.Next; break; } UnsupportedExpression(invocation); break; case ActionType.ConditionalBranch: UnsupportedPredicate("Conditional blocks are not supported."); break; case ActionType.Branch: block = ((BranchActionBlock)block).Target; break; case ActionType.Assign: { AssignActionBlock assignBlock = (AssignActionBlock)block; AssignExpression assign = assignBlock.AssignExpression; VariableReferenceExpression variable = assign.Target as VariableReferenceExpression; if (null == variable) { UnsupportedExpression(assign); } else { if (variables.ContainsKey(variable.Variable.Index)) UnsupportedExpression(assign.Expression); variables.Add(variable.Variable.Index, assign.Expression); block = assignBlock.Next; } break; } case ActionType.Return: { Expression expression = ((ReturnActionBlock)block).Expression; VariableReferenceExpression variable = expression as VariableReferenceExpression; return null == variable ? expression : variables[variable.Variable.Index]; } } } return null; } private static bool IsNoSideEffectIndirectActivationInvocation(MethodInvocationExpression invocation) { MethodDefinition methodDefinition = MethodDefinitionFor(invocation); if (null == methodDefinition) return false; ActionFlowGraph afg = FlowGraphFactory.CreateActionFlowGraph(FlowGraphFactory.CreateControlFlowGraph(methodDefinition)); if (afg.Blocks.Count == 2 && afg.Blocks[0].ActionType == ActionType.Invoke) { InvokeActionBlock invocationBlock = (InvokeActionBlock) afg.Blocks[0]; return IsActivateInvocation(invocationBlock.Expression); } return false; } private static MethodDefinition MethodDefinitionFor(MethodInvocationExpression invocation) { MethodReferenceExpression methodRef = invocation.Target as MethodReferenceExpression; if (null == methodRef) return null; return GetMethodDefinition(methodRef); } private static bool IsActivateInvocation(MethodInvocationExpression invocation) { MethodReferenceExpression methodRef = invocation.Target as MethodReferenceExpression; if (null == methodRef) return false; return IsActivateMethod(methodRef.Method); } private static bool IsActivateMethod(MethodReference method) { if (method.Name != "Activate") return false; return method.DeclaringType.FullName == typeof(IActivatable).FullName || IsOverridenActivateMethod(method); } private static bool IsOverridenActivateMethod(MethodReference method) { TypeDefinition declaringType = FindTypeDefinition(method.DeclaringType.Module, method.DeclaringType.FullName); if (!DeclaringTypeImplementsIActivatable(declaringType)) return false; if (method.Parameters.Count != 1 || method.Parameters[0].ParameterType.FullName != typeof(ActivationPurpose).FullName) return false; return true; } private static bool DeclaringTypeImplementsIActivatable(TypeDefinition type) { foreach (TypeReference itf in type.Interfaces) { if (itf.FullName == typeof (IActivatable).FullName) { return true; } } return false; } private static MethodDefinition GetMethodDefinition(MethodReferenceExpression methodRef) { MethodDefinition definition = methodRef.Method as MethodDefinition; return definition ?? LoadExternalMethodDefinition(methodRef); } private static MethodDefinition LoadExternalMethodDefinition(MethodReferenceExpression methodRef) { MethodReference method = methodRef.Method; AssemblyDefinition assemblyDef = new AssemblyResolver(_assemblyCachingStrategy).ForTypeReference(method.DeclaringType); TypeDefinition type = assemblyDef.MainModule.GetType(method.DeclaringType.FullName); return GetMethod(type, method); } private static MethodDefinition GetMethod(TypeDefinition type, MethodReference template) { foreach (MethodDefinition method in type.Methods) { if (method.Name != template.Name) continue; if (method.Parameters.Count != template.Parameters.Count) continue; if (!ParametersMatch(method.Parameters, template.Parameters)) continue; return method; } return null; } #if CF private static bool ParametersMatch(Collection parameters, IList templates) { return ParametersMatch(parameters, templates, delegate(ParameterDefinition candidate, TypeReference template) { return candidate.ParameterType.FullName == template.FullName; }); } #endif private static bool ParametersMatch(IList parameters, IList templates) { return ParametersMatch(parameters, templates, delegate(ParameterDefinition candidate, ParameterDefinition template) { return candidate.ParameterType.FullName == template.ParameterType.FullName; }); } private static bool ParametersMatch(IList parameters, IList templates, ParameterMatch predicate) { if (parameters.Count != templates.Count) return false; for (int i = 0; i < parameters.Count; i++) { ParameterDefinition parameter = parameters[i]; if (!predicate(parameter, templates[i])) return false; } return true; } private delegate bool ParameterMatch(ParameterDefinition candidate, T template); class Visitor : AbstractCodeStructureVisitor { private object _current; private int _insideCandidate; readonly IList _methodDefinitionStack = new ArrayList(); private readonly CecilReferenceProvider _referenceProvider; public Visitor(MethodDefinition topLevelMethod, AssemblyResolver resolver) { EnterMethodDefinition(topLevelMethod); AssemblyDefinition assembly = resolver.ForType(topLevelMethod.DeclaringType); _referenceProvider = CecilReferenceProvider.ForModule(assembly.MainModule); } private void EnterMethodDefinition(MethodDefinition method) { _methodDefinitionStack.Add(method); } private void LeaveMethodDefinition(MethodDefinition method) { int lastIndex = _methodDefinitionStack.Count - 1; object popped = _methodDefinitionStack[lastIndex]; System.Diagnostics.Debug.Assert(method == popped); _methodDefinitionStack.RemoveAt(lastIndex); } public NQExpression Expression { get { ConstValue value = _current as ConstValue; if (null != value) { return ToNQExpression(value); } return (NQExpression)_current; } } private static NQExpression ToNQExpression(ConstValue value) { if (IsTrue(value.Value())) return BoolConstExpression.True; return BoolConstExpression.False; } private static bool IsTrue(object o) { return ((IConvertible) o).ToBoolean(null); } private bool InsideCandidate { get { return _insideCandidate > 0; } } public override void Visit(CastExpression node) { node.Target.Accept(this); } public override void Visit(AssignExpression node) { UnsupportedExpression(node); } public override void Visit(VariableReferenceExpression node) { UnsupportedExpression(node); } public override void Visit(ArgumentReferenceExpression node) { UnsupportedExpression(node); } public override void Visit(UnaryExpression node) { switch (node.Operator) { case UnaryOperator.Not: Visit(node.Operand); Negate(); break; default: UnsupportedExpression(node); break; } } public override void Visit(Ast.BinaryExpression node) { switch (node.Operator) { case BinaryOperator.ValueEquality: PushComparison(node.Left, node.Right, ComparisonOperator.ValueEquality); break; case BinaryOperator.ValueInequality: PushComparison(node.Left, node.Right, ComparisonOperator.ValueEquality); Negate(); break; case BinaryOperator.LessThan: PushComparison(node.Left, node.Right, ComparisonOperator.Smaller); break; case BinaryOperator.GreaterThan: PushComparison(node.Left, node.Right, ComparisonOperator.Greater); break; case BinaryOperator.GreaterThanOrEqual: PushComparison(node.Left, node.Right, ComparisonOperator.Smaller); Negate(); break; case BinaryOperator.LessThanOrEqual: PushComparison(node.Left, node.Right, ComparisonOperator.Greater); Negate(); break; case BinaryOperator.LogicalOr: Push(new OrExpression(Convert(node.Left), Convert(node.Right))); break; case BinaryOperator.LogicalAnd: Push(new AndExpression(Convert(node.Left), Convert(node.Right))); break; default: UnsupportedExpression(node); break; } } private void Negate() { NQExpression top = (NQExpression)Pop(); NotExpression topNot = top as NotExpression; if (topNot != null) { Push(topNot.Expr()); return; } Push(new NotExpression(top)); } private void PushComparison(Expression lhs, Expression rhs, ComparisonOperator op) { Visit(lhs); object left = Pop(); Visit(rhs); object right = Pop(); bool areOperandsSwapped = IsCandidateFieldValue(right); if (areOperandsSwapped) { object temp = left; left = right; right = temp; } AssertType(left, typeof(FieldValue), lhs); AssertType(right, typeof(IComparisonOperand), rhs); Push(new ComparisonExpression((FieldValue)left, (IComparisonOperand)right, op)); if (areOperandsSwapped && !op.IsSymmetric()) { Negate(); } } private static bool IsCandidateFieldValue(object o) { FieldValue value = o as FieldValue; if (value == null) return false; return value.Root() is CandidateFieldRoot; } public override void Visit(MethodInvocationExpression node) { MethodReferenceExpression methodRef = node.Target as MethodReferenceExpression; if (null == methodRef) UnsupportedExpression(node); MethodReference method = methodRef.Method; if (IsOperator(method)) { ProcessOperatorMethodInvocation(node, method); return; } if (IsSystemString(method.DeclaringType)) { ProcessStringMethod(node, methodRef); return; } ProcessRegularMethodInvocation(node, methodRef); } private static bool IsSystemString(TypeReference type) { return type.FullName == "System.String"; } private void ProcessStringMethod(MethodInvocationExpression node, MethodReferenceExpression methodRef) { MethodReference method = methodRef.Method; if (method.Parameters.Count != 1 || !IsSystemString(method.Parameters[0].ParameterType)) { UnsupportedExpression(methodRef); } switch (method.Name) { case "Contains": PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.Contains); break; case "StartsWith": PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.StartsWith); break; case "EndsWith": PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.EndsWith); break; case "Equals": PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.ValueEquality); break; default: UnsupportedExpression(methodRef); break; } } private void ProcessRegularMethodInvocation(MethodInvocationExpression node, MethodReferenceExpression methodRef) { if (node.Arguments.Count != 0) UnsupportedExpression(node); Expression target = methodRef.Target; switch (target.CodeElementType) { case CodeElementType.ThisReferenceExpression: if (!InsideCandidate) UnsupportedExpression(node); ProcessCandidateMethodInvocation(node, methodRef); break; case CodeElementType.ArgumentReferenceExpression: ProcessCandidateMethodInvocation(node, methodRef); break; default: Push(ToFieldValue(target)); ProcessCandidateMethodInvocation(node, methodRef); break; } } private void ProcessOperatorMethodInvocation(MethodInvocationExpression node, MemberReference methodReference) { switch (methodReference.Name) { case "op_Equality": PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.ValueEquality); break; case "op_Inequality": PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.ValueEquality); Negate(); break; // XXX: check if the operations below are really supported for the // data types in question case "op_GreaterThanOrEqual": PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Smaller); Negate(); break; case "op_LessThanOrEqual": PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Greater); Negate(); break; case "op_LessThan": PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Smaller); break; case "op_GreaterThan": PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Greater); break; default: UnsupportedExpression(node); break; } } private void ProcessCandidateMethodInvocation(Expression methodInvocationExpression, MethodReferenceExpression methodRef) { MethodDefinition method = GetMethodDefinition(methodRef); if (null == method) UnsupportedExpression(methodInvocationExpression); AssertMethodCanBeVisited(methodInvocationExpression, method); Expression expression = GetQueryExpression(method); if (null == expression) UnsupportedExpression(methodInvocationExpression); EnterCandidateMethod(method); try { Visit(expression); } finally { LeaveCandidateMethod(method); } } private void AssertMethodCanBeVisited(Expression methodInvocationExpression, MethodDefinition method) { if (_methodDefinitionStack.Contains(method)) UnsupportedExpression(methodInvocationExpression); } private void EnterCandidateMethod(MethodDefinition method) { EnterMethodDefinition(method); ++_insideCandidate; } private void LeaveCandidateMethod(MethodDefinition method) { --_insideCandidate; LeaveMethodDefinition(method); } private static bool IsOperator(MethodReference method) { return !method.HasThis && method.Name.StartsWith("op_") && 2 == method.Parameters.Count; } public override void Visit(FieldReferenceExpression node) { PushFieldValueForTarget(node, node.Target); } private void PushFieldValueForTarget(FieldReferenceExpression node, Expression target) { switch (target.CodeElementType) { case CodeElementType.ArgumentReferenceExpression: PushFieldValue(CandidateFieldRoot.Instance, node.Field); break; case CodeElementType.ThisReferenceExpression: if (InsideCandidate) { if (_current != null) { FieldValue current = PopFieldValue(node); PushFieldValue(current, node.Field); } else { PushFieldValue(CandidateFieldRoot.Instance, node.Field); } } else { PushFieldValue(PredicateFieldRoot.Instance, node.Field); } break; case CodeElementType.MethodInvocationExpression: case CodeElementType.FieldReferenceExpression: FieldValue value = ToFieldValue(target); PushFieldValue(value, node.Field); break; case CodeElementType.CastExpression: PushFieldValueForTarget(node, ((CastExpression)node.Target).Target); break; default: UnsupportedExpression(node); break; } } private void PushFieldValue(IComparisonOperandAnchor value, FieldReference field) { Push(new FieldValue(value, _referenceProvider.ForCecilField(field))); } public override void Visit(LiteralExpression node) { Push(new ConstValue(node.Value)); } NQExpression Convert(Expression node) { return ReconstructNullComparisonIfNecessary(node); } private NQExpression ReconstructNullComparisonIfNecessary(Expression node) { Visit(node); object top = Pop(); FieldValue fieldValue = top as FieldValue; if (fieldValue == null) { AssertType(top, typeof(NQExpression), node); return (NQExpression)top; } return new NotExpression( new ComparisonExpression( fieldValue, new ConstValue(null), ComparisonOperator.ValueEquality)); } FieldValue ToFieldValue(Expression node) { Visit(node); return PopFieldValue(node); } private FieldValue PopFieldValue(Expression node) { return (FieldValue)Pop(node, typeof(FieldValue)); } void Push(object value) { Assert(_current == null, "expression stack must be empty before Push"); _current = value; } object Pop(Expression node, Type expectedType) { object value = Pop(); AssertType(value, expectedType, node); return value; } private static void AssertType(object value, Type expectedType, Expression sourceExpression) { Type actualType = value.GetType(); if (!expectedType.IsAssignableFrom(actualType)) { UnsupportedPredicate( string.Format("Unsupported expression: {0}. Unexpected type on stack. Expected: {1}, Got: {2}.", ExpressionPrinter.ToString(sourceExpression), expectedType, actualType)); } } object Pop() { Assert(_current != null, "expression stack is empty"); object value = _current; _current = null; return value; } private static void Assert(bool condition, string message) { System.Diagnostics.Debug.Assert(condition, message); } } } internal class BoxedValueTypeProcessor : TraversingExpressionVisitor { override public void Visit(ComparisonExpression expression) { TypeReference fieldType = GetFieldType(expression.Left()); if (!fieldType.IsValueType) return; ConstValue constValue = expression.Right() as ConstValue; if (constValue == null) return; AdjustConstValue(fieldType, constValue); } private static TypeReference GetFieldType(FieldValue field) { return ((CecilFieldRef) field.Field).FieldType; } private static void AdjustConstValue(TypeReference typeRef, ConstValue constValue) { object value = constValue.Value(); if (!value.GetType().IsValueType) return; System.Type type = ResolveTypeReference(typeRef); if (!type.IsEnum || value.GetType() == type) return; constValue.Value(Enum.ToObject(type, value)); } private static Type ResolveTypeReference(TypeReference typeRef) { Assembly assembly = LoadAssembly(typeRef.Scope); return assembly.GetType(typeRef.FullName.Replace('/', '+'), true); } private static Assembly LoadAssembly(IMetadataScope scope) { AssemblyNameReference nameRef = scope as AssemblyNameReference; if (null != nameRef) return Assembly.Load(nameRef.FullName); ModuleDefinition moduleDef = scope as ModuleDefinition; return LoadAssembly(moduleDef.Assembly.Name); } } }Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/UnsupportedPredicateException.cs000644 001750 001750 00000001561 11520622624 041401 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.NativeQueries { using System; public class UnsupportedPredicateException : Exception { public UnsupportedPredicateException(string reason) : base(reason) { } } } src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/AssemblyResolver.cs000644 001750 001750 00000004565 11520622624 036661 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections.Generic; using System.Reflection; using Db4objects.Db4o.Internal.Query; using Mono.Cecil; namespace Db4objects.Db4o.NativeQueries { internal class AssemblyResolver { public AssemblyResolver(ICachingStrategy assemblyCache) { _assemblyCachingStrategy = assemblyCache; } public AssemblyDefinition ForTypeReference(TypeReference type) { AssemblyNameReference scope = (AssemblyNameReference)type.Scope; string assemblyName = scope.FullName; AssemblyDefinition definition = LookupAssembly(assemblyName); if (null == definition) { Assembly assembly = Assembly.Load(assemblyName); string location = assembly.GetType(type.FullName, true).Module.FullyQualifiedName; definition = _assemblyCachingStrategy.Get(location); RegisterAssembly(definition); } return definition; } private AssemblyDefinition LookupAssembly(string fullName) { return _assemblies.ContainsKey(fullName) ? _assemblies[fullName] : null; } /// /// Registers an assembly so it can be looked up by its assembly name /// string later. /// /// private void RegisterAssembly(AssemblyDefinition assembly) { _assemblies.Add(assembly.Name.FullName, assembly); } public AssemblyDefinition ForType(TypeDefinition type) { AssemblyDefinition assembly = type.Module.Assembly; RegisterAssembly(assembly); return assembly; } private readonly ICachingStrategy _assemblyCachingStrategy; readonly IDictionary _assemblies = new Dictionary(); } } src/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/SingleItemCachingStrategy.cs000644 001750 001750 00000004041 11520622624 040405 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4objects.Db4o.Internal.Query { public delegate R Producer(T arg); /// /// A very simple caching strategy that caches only the last added item. /// public class SingleItemCachingStrategy : ICachingStrategy { private K _lastKey; private V _lastItem; private object _monitor = new object(); private readonly Producer _producer; public SingleItemCachingStrategy(Producer producer) { _producer = producer; } #region ICachingStrategy Members public void Add(K key, V item) { if (!typeof(K).IsValueType && null == key) throw new ArgumentNullException("key"); lock (_monitor) { _lastKey = key; _lastItem = item; } } public V Get(K key) { if (null == key) throw new ArgumentNullException("key"); lock (_monitor) { if (!key.Equals(_lastKey)) { Add(key, _producer(key)); } return _lastItem; } } #endregion } public class NullCachingStrategy : ICachingStrategy { public static readonly ICachingStrategy Default = new NullCachingStrategy(); #region ICachingStrategy Members public void Add(object key, object item) { } public object Get(object key) { return null; } #endregion } }db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-2008.csproj000644 001750 001750 00000016164 11520622044 033425 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.21022 2.0 {AB1BF369-A9C4-4876-9797-178DB8AD437F} Library Properties Db4objects.Db4o.NativeQueries Db4objects.Db4o.NativeQueries 2.0 v3.5 true ../db4objects.snk true full false bin\Debug\ DEBUG;TRACE;NET_3_5 prompt 4 bin\Debug\Db4objects.Db4o.NativeQueries.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;NET_3_5 prompt 4 bin\Release\Db4objects.Db4o.NativeQueries.xml 1591;1572;1573;1574;0419; False ..\Libs\net-2.0\Cecil.FlowAnalysis.dll False ..\Libs\net-2.0\Mono.Cecil.dll 3.5 {FFA59708-14D1-4C22-B9A4-1A389EE796D5} Db4objects.Db4o.Instrumentation-2008 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-2010.csproj000644 001750 001750 00000021006 11520622044 033405 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.21022 2.0 {AB1BF369-A9C4-4876-9797-178DB8AD437F} Library Properties Db4objects.Db4o.NativeQueries Db4objects.Db4o.NativeQueries 3.5 v4.0 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;NET_3_5;NET_4_0 prompt 4 bin\Debug\Db4objects.Db4o.NativeQueries.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;NET_3_5;NET_4_0 prompt 4 bin\Release\Db4objects.Db4o.NativeQueries.xml 1591;1572;1573;1574;0419; False ..\Libs\net-2.0\Cecil.FlowAnalysis.dll False ..\Libs\net-2.0\Mono.Cecil.dll 3.5 False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {DFE1C46F-BB18-4B6A-AE34-4366F58BEB5A} Db4objects.Db4o.Instrumentation-2010 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Makefile000644 001750 001750 00000000316 11520622054 025710 0ustar00directhexdirecthex000000 000000 include ../../db4o.net/include.mk OUTDIR = ../../db4o.net/bin TARGET = library ASSEMBLY = $(NQ) REFERENCES = -r:$(OUTDIR)/$(CORE) -r:$(OUTDIR)/$(INSTR) -r:$(OUTDIR)/$(CECIL) -r:$(OUTDIR)/$(FLOWANALYSIS) db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Properties/000755 001750 001750 00000000000 11520622052 026402 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.NativeQueries/Properties/AssemblyInfo.cs000644 001750 001750 00000002641 11520622624 031334 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.InteropServices; using System.Security; [assembly: AssemblyTitle("db4o - native query handling")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // attributes are automatically set by the build [assembly: AssemblyVersion("8.0.184.15484")] [assembly: AssemblyKeyFile("")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyDescription("Db4objects.Db4o.NativeQueries 8.0.184.15484 (.NET)")] #if !CF [assembly: AllowPartiallyTrustedCallers] #endif [assembly: ComVisible(false)] db4o-8.0.184.15484+dfsg/src/tools/000755 001750 001750 00000000000 11621751251 020057 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/000755 001750 001750 00000000000 11520622066 023560 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/native/000755 001750 001750 00000000000 11520622040 025036 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/000755 001750 001750 00000000000 11520622042 030116 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/000755 001750 001750 00000000000 11520622070 032244 5ustar00directhexdirecthex000000 000000 native/Db4objects.Db4o.CS/Monitoring/ClientConnectionsMonitoringSupport.cs000644 001750 001750 00000003130 11520622622 041600 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.CS.Config; using Db4objects.Db4o.CS.Internal; using Db4objects.Db4o.Internal; namespace Db4objects.Db4o.CS.Monitoring { public class ClientConnectionsMonitoringSupport : IServerConfigurationItem { public void Prepare(IServerConfiguration configuration) { } public void Apply(IObjectServer server) { PerformanceCounter clientConnections = null; ObjectContainerBase container = (ObjectContainerBase) server.Ext().ObjectContainer(); container.WithEnvironment(delegate { clientConnections = Db4oClientServerPerformanceCounters.CounterForNetworkingClientConnections(server); }); ServerEventsFor(server).Closed += delegate { clientConnections.RemoveInstance();}; } private static IObjectServerEvents ServerEventsFor(IObjectServer server) { return ((IObjectServerEvents) server); } } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/MonitoredServerSocket4.cs000644 001750 001750 00000002420 11520622622 037101 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.CS.Foundation; namespace Db4objects.Db4o.CS.Monitoring { public class MonitoredServerSocket4 : ServerSocket4Decorator { public MonitoredServerSocket4(IServerSocket4 serverSocket) : base(serverSocket) { _serverSocket = serverSocket; } public override ISocket4 Accept() { return new MonitoredServerSideClientSocket4(_serverSocket.Accept(), _counters); } public override void Close() { base.Close(); _counters.Close(); } private readonly NetworkingCounters _counters = new NetworkingCounters(); } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/MonitoredClientSocket4.cs000644 001750 001750 00000002331 11520622622 037052 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.CS.Foundation; namespace Db4objects.Db4o.CS.Monitoring { public class MonitoredClientSocket4 : MonitoredSocket4Base { public MonitoredClientSocket4(ISocket4 socket) : base(socket) { } public override void Close() { base.Close(); _counters.Close(); } protected override NetworkingCounters Counters() { if (null == _counters) { _counters = new NetworkingCounters(); } return _counters; } private NetworkingCounters _counters; } } #endifDb4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/MonitoredServerSideClientSocket4.cs000644 001750 001750 00000002207 11520622622 041050 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.CS.Foundation; namespace Db4objects.Db4o.CS.Monitoring { public class MonitoredServerSideClientSocket4 : MonitoredSocket4Base { public MonitoredServerSideClientSocket4(ISocket4 socket, NetworkingCounters counters) : base(socket) { _counters = counters; } protected override NetworkingCounters Counters() { return _counters; } private readonly NetworkingCounters _counters; } } #endifnative/Db4objects.Db4o.CS/Monitoring/Db4oClientServerPerformanceCounters.cs000644 001750 001750 00000003326 11520622622 041546 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.CS.Internal; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Monitoring; namespace Db4objects.Db4o.CS.Monitoring { public class Db4oClientServerPerformanceCounters : Db4oPerformanceCounters { public static PerformanceCounter CounterForNetworkingClientConnections(IObjectServer server) { PerformanceCounter clientConnections = NewDb4oCounter(PerformanceCounterSpec.NetClientConnections.Id, false); IObjectServerEvents serverEvents = (IObjectServerEvents) server; serverEvents.ClientConnected += delegate { clientConnections.Increment(); }; serverEvents.ClientDisconnected += delegate { clientConnections.Decrement(); }; return clientConnections; } /* * TODO: Remove */ private static PerformanceCounter NewDb4oCounter(string counterName, bool readOnly) { string instanceName = My.Instance.ToString(); return NewDb4oCounter(counterName, instanceName, readOnly); } } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/MonitoredSocket4Factory.cs000644 001750 001750 00000002622 11520622622 037246 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.CS.Foundation; namespace Db4objects.Db4o.CS.Monitoring { public class MonitoredSocket4Factory : ISocket4Factory { private readonly ISocket4Factory _socketFactory; public MonitoredSocket4Factory(ISocket4Factory socketFactory) { _socketFactory = socketFactory; } public ISocket4 CreateSocket(string hostName, int port) { return new MonitoredClientSocket4(_socketFactory.CreateSocket(hostName, port)); } public IServerSocket4 CreateServerSocket(int port) { return new MonitoredServerSocket4(_socketFactory.CreateServerSocket(port)); } } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/NetworkingCounters.cs000644 001750 001750 00000003753 11520622622 036401 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Diagnostics; using Db4objects.Db4o.Monitoring; namespace Db4objects.Db4o.CS.Monitoring { public class NetworkingCounters { internal PerformanceCounter BytesSent() { if (null == _bytesSent) { _bytesSent = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.NetBytesSentPerSec, false); } return _bytesSent; } internal PerformanceCounter BytesReceived() { if (null == _bytesReceived) { _bytesReceived = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.NetBytesReceivedPerSec, false); } return _bytesReceived; } internal PerformanceCounter MessagesSent() { if (null == _messagesSent) { _messagesSent = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.NetMessagesSentPerSec, false); } return _messagesSent; } public void Close() { Dispose(_bytesSent); Dispose(_bytesReceived); Dispose(_messagesSent); } private static void Dispose(PerformanceCounter counter) { if (null != counter) { counter.RemoveInstance(); counter.Dispose(); } } private PerformanceCounter _bytesSent; private PerformanceCounter _bytesReceived; private PerformanceCounter _messagesSent; } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/MonitoredSocket4Base.cs000644 001750 001750 00000002637 11520622622 036517 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.CS.Foundation; namespace Db4objects.Db4o.CS.Monitoring { public abstract class MonitoredSocket4Base : Socket4Decorator { protected MonitoredSocket4Base(ISocket4 socket) : base(socket) { } public override void Write(byte[] bytes, int offset, int count) { base.Write(bytes, offset, count); Counters().BytesSent().IncrementBy(count); Counters().MessagesSent().Increment(); } public override int Read(byte[] buffer, int offset, int count) { int bytesReceived = base.Read(buffer, offset, count); Counters().BytesReceived().IncrementBy(bytesReceived); return bytesReceived; } protected abstract NetworkingCounters Counters(); } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Monitoring/NetworkingMonitoringSupport.cs000644 001750 001750 00000002736 11520622622 040321 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using Db4objects.Db4o.Config; using Db4objects.Db4o.CS.Config; using Db4objects.Db4o.CS.Foundation; using Db4objects.Db4o.CS.Internal.Config; using Db4objects.Db4o.Internal; namespace Db4objects.Db4o.CS.Monitoring { public class NetworkingMonitoringSupport:IConfigurationItem { public void Prepare(IConfiguration configuration) { INetworkingConfiguration networkConfig = Db4oClientServerLegacyConfigurationBridge.AsNetworkingConfiguration(configuration); ISocket4Factory currentSocketFactory = networkConfig.SocketFactory; networkConfig.SocketFactory = new MonitoredSocket4Factory(currentSocketFactory); } public void Apply(IInternalObjectContainer container) { } } } #endifdb4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Foundation/000755 001750 001750 00000000000 11520622070 032225 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Foundation/ServerSslSocket.cs000644 001750 001750 00000002270 11520622622 035602 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Security.Cryptography.X509Certificates; namespace Db4objects.Db4o.CS.Foundation { internal class ServerSslSocket : ServerSocket4Decorator { public ServerSslSocket(IServerSocket4 socket, X509Certificate2 certificate) : base(socket) { _certificate = certificate; } public override ISocket4 Accept() { ISocket4 socket = base.Accept(); return new SslSocket(socket, _certificate); } private readonly X509Certificate2 _certificate; } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Foundation/Socket4Stream.cs000644 001750 001750 00000003531 11520622622 035172 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; namespace Db4objects.Db4o.CS.Foundation { internal class Socket4Stream : Stream { public Socket4Stream(ISocket4 socket) { _socket = socket; } public override void Flush() { _socket.Flush(); } public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public override void SetLength(long value) { throw new NotSupportedException(); } public override int Read(byte[] buffer, int offset, int count) { return _socket.Read(buffer, offset, count); } public override void Write(byte[] buffer, int offset, int count) { _socket.Write(buffer, offset, count); } public override bool CanRead { get { return true ; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return true; } } public override long Length { get { throw new NotSupportedException(); } } public override long Position { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } private readonly ISocket4 _socket; } }src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Foundation/SslSocket.cs000644 001750 001750 00000004170 11520622622 034414 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System; using System.Net.Security; using System.Security.Cryptography.X509Certificates; namespace Db4objects.Db4o.CS.Foundation { internal class SslSocket : ISocket4 { private SslSocket(ISocket4 socket) { _socket = socket; } public SslSocket(ISocket4 socket, string hostName, RemoteCertificateValidationCallback certificateValidationCallback) : this(socket) { _sslStream = new SslStream(new Socket4Stream(socket), false, certificateValidationCallback); _sslStream.AuthenticateAsClient(hostName); } public SslSocket(ISocket4 socket, X509Certificate2 certificate) : this(socket) { _sslStream = new SslStream(new Socket4Stream(socket), false); _sslStream.AuthenticateAsServer(certificate); } public void Close() { _sslStream.Close(); } public void Flush() { _sslStream.Flush(); } public void SetSoTimeout(int timeout) { _socket.SetSoTimeout(timeout); } public bool IsConnected() { return _socket.IsConnected(); } public int Read(byte[] buffer, int offset, int count) { return _sslStream.Read(buffer, offset, count); } public void Write(byte[] bytes, int offset, int count) { _sslStream.Write(bytes, offset, count); } public ISocket4 OpenParallelSocket() { throw new NotImplementedException(); } private readonly SslStream _sslStream; private readonly ISocket4 _socket; } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Foundation/SslSocketFactory.cs000644 001750 001750 00000003470 11520622622 035746 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Net.Security; using System.Security.Cryptography.X509Certificates; namespace Db4objects.Db4o.CS.Foundation { public class SslSocketFactory : ISocket4Factory { public SslSocketFactory(ISocket4Factory delegating, X509Certificate2 certificate) { _certificate = certificate; _delegating = delegating; } public SslSocketFactory(ISocket4Factory delegating, RemoteCertificateValidationCallback validationCallback) { _delegating = delegating; _validationCallback = validationCallback; } public ISocket4 CreateSocket(string hostName, int port) { ISocket4 clientSocket = _delegating.CreateSocket(hostName, port); return new SslSocket(clientSocket, hostName, _validationCallback); } public IServerSocket4 CreateServerSocket(int port) { IServerSocket4 serverSocket = _delegating.CreateServerSocket(port); return new ServerSslSocket(serverSocket, _certificate); } private readonly ISocket4Factory _delegating; private readonly X509Certificate2 _certificate; private readonly RemoteCertificateValidationCallback _validationCallback; } } #endifdb4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Config/000755 001750 001750 00000000000 11520622044 031325 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Config/ClientSslSupport.cs000644 001750 001750 00000002560 11520622622 035077 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Net.Security; using Db4objects.Db4o.CS.Foundation; using Db4objects.Db4o.Ext; namespace Db4objects.Db4o.CS.Config { public class ClientSslSupport : IClientConfigurationItem { public ClientSslSupport(RemoteCertificateValidationCallback validationCallback) { _validationCallback = validationCallback; } public void Prepare(IClientConfiguration configuration) { configuration.Networking.SocketFactory = new SslSocketFactory(configuration.Networking.SocketFactory, _validationCallback); } public void Apply(IExtClient client) { } private readonly RemoteCertificateValidationCallback _validationCallback; } } #endifsrc/Db4objects.Db4o.CS.Optional/native/Db4objects.Db4o.CS/Config/ServerSslSupport.cs000644 001750 001750 00000002447 11520622622 035133 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System.Security.Cryptography.X509Certificates; using Db4objects.Db4o.CS.Foundation; namespace Db4objects.Db4o.CS.Config { public class ServerSslSupport : IServerConfigurationItem { public ServerSslSupport(X509Certificate2 certificate) { _certificate = certificate; } public void Prepare(IServerConfiguration configuration) { configuration.Networking.SocketFactory = new SslSocketFactory(configuration.Networking.SocketFactory, _certificate); } public void Apply(IObjectServer server) { } private readonly X509Certificate2 _certificate; } } #endifdb4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/Db4objects.Db4o.CS.Optional-2010.csproj000644 001750 001750 00000013664 11520622066 032236 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {2DC5A1FA-7BD9-4937-9E36-2EED126B7809} Library Properties DB4objects.Db4o.CS.Optional DB4objects.Db4o.CS.Optional v4.0 512 3.5 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;NET_3_5;NET_4_0 prompt 4 bin\Debug/DB4objects.Db4o.CS.Optional.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;NET_3_5;NET_4_0 prompt 4 1591;1572;1573;1574;0419; bin\Release/DB4objects.Db4o.CS.Optional.xml False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {9FA8178A-3E77-42C5-A252-6690EA9BA257} Db4objects.Db4o.CS-2010 {E9588FE7-C19D-445E-BB53-AE539EA4F0E6} Db4objects.Db4o.Optional-2010 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/Db4objects.Db4o.CS.Optional-2008.csproj000644 001750 001750 00000010647 11520622040 032233 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {2DC5A1FA-7BD9-4937-9E36-2EED126B7809} Library Properties DB4objects.Db4o.CS.Optional DB4objects.Db4o.CS.Optional v3.5 512 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;NET_3_5 prompt 4 bin\Debug/DB4objects.Db4o.CS.Optional.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;NET_3_5 prompt 4 1591;1572;1573;1574;0419; bin\Release/DB4objects.Db4o.CS.Optional.xml {9FA8178A-3E77-42C5-A252-6690EA9BA257} Db4objects.Db4o.CS-2008 {E9588FE7-C19D-445E-BB53-AE539EA4F0E6} Db4objects.Db4o.Optional-2008 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/Db4objects.Db4o.CS.Optional-CF-2008.csproj000644 001750 001750 00000013657 11520622064 032533 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {16C8C5B5-2755-4F64-A901-FC62D0F1D9D6} Library Properties DB4objects.Db4o.CS.Optional DB4objects.Db4o.CS.Optional {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 DB4objects.Db4o.CS.Optional_CF_2008 v3.5 2.0 Pocket PC 2003 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;CF_3_5;CF;$(PlatformFamilyName) true true prompt 512 4 Off bin\Debug/DB4objects.Db4o.CS.Optional.xml 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;CF_3_5;CF;$(PlatformFamilyName) true true prompt 512 4 Off 1591;1572;1573;1574;0419; bin\Release/DB4objects.Db4o.CS.Optional.xml False D:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.Core.dll {89BB3D10-B9D5-4172-A0D9-3BB856AC5B85} Db4objects.Db4o.CS-CF-2008 {667C616E-FEA2-4D5E-93F0-9D18D17275FA} Db4objects.Db4o.Optional-CF-2008 {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/Properties/000755 001750 001750 00000000000 11520622050 025705 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.CS.Optional/Properties/AssemblyInfo.cs000644 001750 001750 00000002421 11520622622 030633 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using System.Runtime.InteropServices; using System.Security; [assembly: AssemblyTitle("db4o - optional cs functionality")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture ("")] [assembly: ComVisible (false)] [assembly: AssemblyVersion("8.0.184.15484")] #if !CF && !SILVERLIGHT [assembly: AllowPartiallyTrustedCallers] #endif [assembly: CLSCompliant(true)]db4o-8.0.184.15484+dfsg/src/Db4o-Silverlight-2010.sln000644 001750 001750 00000015565 11520622054 023107 0ustar00directhexdirecthex000000 000000  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-Silverlight-2010", "Db4objects.Db4o\Db4objects.Db4o-Silverlight-2010.csproj", "{76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Optional-Silverlight-2010", "Db4objects.Db4o.Optional\Db4objects.Db4o.Optional-Silverlight-2010.csproj", "{97B6DEA6-255B-4B49-8973-38943AC2E70C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Silverlight.TestStart-2010", "Db4objects.Db4o.Silverlight.TestStart\Db4objects.Db4o.Silverlight.TestStart-2010.csproj", "{A639AD3D-08FB-41D5-A770-B8BE540C369D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.SilverlightTestHost-2010", "Db4objects.Db4o.SilverlightTestHost\Db4objects.Db4o.SilverlightTestHost-2010.csproj", "{2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Tests-Silverlight-2010", "Db4objects.Db4o.Tests\Db4objects.Db4o.Tests-Silverlight-2010.csproj", "{C388ABDD-CB2C-4438-8942-C3A935AC8E2D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit-Silverlight-2010", "Db4oUnit\Db4oUnit-Silverlight-2010.csproj", "{C74364D8-A04A-4CF9-801D-D1811D49E72A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit.Extensions-Silverlight-2010", "Db4oUnit.Extensions\Db4oUnit.Extensions-Silverlight-2010.csproj", "{13B5E015-9250-4E70-939D-56233D43D8C3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq-Silverlight-2010", "Db4objects.Db4o.Linq\Db4objects.Db4o.Linq-Silverlight-2010.csproj", "{2E56236C-E595-4DFF-9B9E-0E0509D29A4E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq.Tests-Silverlight-2010", "Db4objects.Db4o.Linq.Tests\Db4objects.Db4o.Linq.Tests-Silverlight-2010.csproj", "{3384A556-4CE5-4959-B25B-59C2506B52E7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}.Debug|Any CPU.Build.0 = Debug|Any CPU {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}.Debug|x86.ActiveCfg = Debug|Any CPU {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}.Release|Any CPU.ActiveCfg = Release|Any CPU {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}.Release|Any CPU.Build.0 = Release|Any CPU {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65}.Release|x86.ActiveCfg = Release|Any CPU {97B6DEA6-255B-4B49-8973-38943AC2E70C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {97B6DEA6-255B-4B49-8973-38943AC2E70C}.Debug|Any CPU.Build.0 = Debug|Any CPU {97B6DEA6-255B-4B49-8973-38943AC2E70C}.Debug|x86.ActiveCfg = Debug|Any CPU {97B6DEA6-255B-4B49-8973-38943AC2E70C}.Release|Any CPU.ActiveCfg = Release|Any CPU {97B6DEA6-255B-4B49-8973-38943AC2E70C}.Release|Any CPU.Build.0 = Release|Any CPU {97B6DEA6-255B-4B49-8973-38943AC2E70C}.Release|x86.ActiveCfg = Release|Any CPU {A639AD3D-08FB-41D5-A770-B8BE540C369D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A639AD3D-08FB-41D5-A770-B8BE540C369D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A639AD3D-08FB-41D5-A770-B8BE540C369D}.Debug|x86.ActiveCfg = Debug|Any CPU {A639AD3D-08FB-41D5-A770-B8BE540C369D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A639AD3D-08FB-41D5-A770-B8BE540C369D}.Release|Any CPU.Build.0 = Release|Any CPU {A639AD3D-08FB-41D5-A770-B8BE540C369D}.Release|x86.ActiveCfg = Release|Any CPU {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Debug|x86.ActiveCfg = Debug|x86 {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Debug|x86.Build.0 = Debug|x86 {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Release|Any CPU.Build.0 = Release|Any CPU {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Release|x86.ActiveCfg = Release|x86 {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59}.Release|x86.Build.0 = Release|x86 {C388ABDD-CB2C-4438-8942-C3A935AC8E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C388ABDD-CB2C-4438-8942-C3A935AC8E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU {C388ABDD-CB2C-4438-8942-C3A935AC8E2D}.Debug|x86.ActiveCfg = Debug|Any CPU {C388ABDD-CB2C-4438-8942-C3A935AC8E2D}.Release|Any CPU.ActiveCfg = Release|Any CPU {C388ABDD-CB2C-4438-8942-C3A935AC8E2D}.Release|Any CPU.Build.0 = Release|Any CPU {C388ABDD-CB2C-4438-8942-C3A935AC8E2D}.Release|x86.ActiveCfg = Release|Any CPU {C74364D8-A04A-4CF9-801D-D1811D49E72A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C74364D8-A04A-4CF9-801D-D1811D49E72A}.Debug|Any CPU.Build.0 = Debug|Any CPU {C74364D8-A04A-4CF9-801D-D1811D49E72A}.Debug|x86.ActiveCfg = Debug|Any CPU {C74364D8-A04A-4CF9-801D-D1811D49E72A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C74364D8-A04A-4CF9-801D-D1811D49E72A}.Release|Any CPU.Build.0 = Release|Any CPU {C74364D8-A04A-4CF9-801D-D1811D49E72A}.Release|x86.ActiveCfg = Release|Any CPU {13B5E015-9250-4E70-939D-56233D43D8C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {13B5E015-9250-4E70-939D-56233D43D8C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {13B5E015-9250-4E70-939D-56233D43D8C3}.Debug|x86.ActiveCfg = Debug|Any CPU {13B5E015-9250-4E70-939D-56233D43D8C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {13B5E015-9250-4E70-939D-56233D43D8C3}.Release|Any CPU.Build.0 = Release|Any CPU {13B5E015-9250-4E70-939D-56233D43D8C3}.Release|x86.ActiveCfg = Release|Any CPU {2E56236C-E595-4DFF-9B9E-0E0509D29A4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E56236C-E595-4DFF-9B9E-0E0509D29A4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E56236C-E595-4DFF-9B9E-0E0509D29A4E}.Debug|x86.ActiveCfg = Debug|Any CPU {2E56236C-E595-4DFF-9B9E-0E0509D29A4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E56236C-E595-4DFF-9B9E-0E0509D29A4E}.Release|Any CPU.Build.0 = Release|Any CPU {2E56236C-E595-4DFF-9B9E-0E0509D29A4E}.Release|x86.ActiveCfg = Release|Any CPU {3384A556-4CE5-4959-B25B-59C2506B52E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3384A556-4CE5-4959-B25B-59C2506B52E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {3384A556-4CE5-4959-B25B-59C2506B52E7}.Debug|x86.ActiveCfg = Debug|Any CPU {3384A556-4CE5-4959-B25B-59C2506B52E7}.Release|Any CPU.ActiveCfg = Release|Any CPU {3384A556-4CE5-4959-B25B-59C2506B52E7}.Release|Any CPU.Build.0 = Release|Any CPU {3384A556-4CE5-4959-B25B-59C2506B52E7}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/Db4oUnit/000755 001750 001750 00000000000 11520622070 020341 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit-CF-2008.csproj000644 001750 001750 00000024373 11520622070 024101 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7} Library Properties Db4oUnit Db4oUnit {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 Db4oUnit_CF_2008 v3.5 2.0 Pocket PC 2003 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;CF_3_5;CF;$(PlatformFamilyName) true true prompt 512 4 Off 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;CF;CF_3_5;$(PlatformFamilyName) true true prompt 512 4 Off 1591;1572;1573;1574;0419; False C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\mscorlib.dll False C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.dll {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit-Silverlight-2008.csproj000644 001750 001750 00000023071 11520622060 026076 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {C74364D8-A04A-4CF9-801D-D1811D49E72A} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4oUnit Db4oUnit v3.5 false true true true ../db4objects.snk true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2008 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/000755 001750 001750 00000000000 11520622040 021766 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/000755 001750 001750 00000000000 11520622070 023421 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Check.cs000644 001750 001750 00000003161 11520622622 024771 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { /// /// Utility class to enable the reuse of object comparison and checking /// methods without asserting. /// /// /// Utility class to enable the reuse of object comparison and checking /// methods without asserting. /// public class Check { public static bool ObjectsAreEqual(object expected, object actual) { return expected == actual || (expected != null && actual != null && expected.Equals (actual)); } public static bool ArraysAreEqual(object[] expected, object[] actual) { if (expected == actual) { return true; } if (expected == null || actual == null) { return false; } if (expected.Length != actual.Length) { return false; } for (int i = 0; i < expected.Length; i++) { if (!ObjectsAreEqual(expected[i], actual[i])) { return false; } } return true; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TestMethod.cs000644 001750 001750 00000006013 11520622622 026033 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { /// Reflection based db4ounit.Test implementation. /// Reflection based db4ounit.Test implementation. public class TestMethod : ITest { private readonly object _subject; private readonly MethodInfo _method; public TestMethod(object instance, MethodInfo method) { if (null == instance) { throw new ArgumentException("instance"); } if (null == method) { throw new ArgumentException("method"); } _subject = instance; _method = method; } public virtual object GetSubject() { return _subject; } public virtual MethodInfo GetMethod() { return _method; } public virtual string Label() { return _subject.GetType().FullName + "." + _method.Name; } public override string ToString() { return "TestMethod(" + _method + ")"; } public virtual void Run() { bool exceptionInTest = false; try { try { SetUp(); Invoke(); } catch (TargetInvocationException x) { exceptionInTest = true; throw new TestException(x.InnerException); } catch (Exception x) { exceptionInTest = true; throw new TestException(x); } } finally { try { TearDown(); } catch (Exception exc) { if (!exceptionInTest) { throw; } Sharpen.Runtime.PrintStackTrace(exc); } } } /// protected virtual void Invoke() { _method.Invoke(_subject, new object[0]); } protected virtual void TearDown() { if (_subject is ITestLifeCycle) { try { ((ITestLifeCycle)_subject).TearDown(); } catch (Exception e) { throw new TearDownFailureException(e); } } } protected virtual void SetUp() { if (_subject is ITestLifeCycle) { try { ((ITestLifeCycle)_subject).SetUp(); } catch (Exception e) { throw new SetupFailureException(e); } } } public virtual bool IsLeafTest() { return true; } public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TestFailure.cs000644 001750 001750 00000002744 11520622622 026211 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4oUnit; namespace Db4oUnit { public class TestFailure : Printable { private readonly string _testLabel; private readonly Exception _failure; public TestFailure(string test, Exception failure) { _testLabel = test; _failure = failure; } public virtual string TestLabel { get { return _testLabel; } } public virtual Exception Reason { get { return _failure; } } /// public override void Print(TextWriter writer) { writer.Write(_testLabel); writer.Write(": "); // TODO: don't print the first stack trace elements // which reference db4ounit.Assert methods TestPlatform.PrintStackTrace(writer, _failure); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/JaggedArrayAssert.cs000644 001750 001750 00000003173 11520622622 027321 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit { public class JaggedArrayAssert { public static void AreEqual(object[][] expected, object[][] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); Assert.AreSame(expected.GetType(), actual.GetType()); for (int i = 0; i < expected.Length; i++) { ArrayAssert.AreEqual(expected[i], actual[i]); } } public static void AreEqual(int[][] expected, int[][] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); Assert.AreSame(expected.GetType(), actual.GetType()); for (int i = 0; i < expected.Length; i++) { ArrayAssert.AreEqual(expected[i], actual[i]); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestListener.cs000644 001750 001750 00000001705 11520622622 026514 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { public interface ITestListener { void RunStarted(); void TestStarted(ITest test); void TestFailed(ITest test, Exception failure); void RunFinished(); void Failure(string msg, Exception failure); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/SetupFailureException.cs000644 001750 001750 00000001703 11520622622 030243 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { [System.Serializable] public class SetupFailureException : TestException { private const long serialVersionUID = -7835097105469071064L; public SetupFailureException(Exception cause) : base(cause) { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/AssertionException.cs000644 001750 001750 00000002053 11520622622 027601 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { [System.Serializable] public partial class AssertionException : TestException { private const long serialVersionUID = 900088031151055525L; public AssertionException(string message) : base(message, null) { } public AssertionException(string message, Exception cause) : base(message, cause) { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ReflectionTestSuiteBuilder.cs000644 001750 001750 00000016271 11520622622 031235 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Reflection; using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public class ReflectionTestSuiteBuilder : ITestSuiteBuilder { private Type[] _classes; public ReflectionTestSuiteBuilder(Type clazz) : this(new Type[] { clazz }) { } public ReflectionTestSuiteBuilder(Type[] classes) { if (null == classes) { throw new ArgumentException("classes"); } _classes = classes; } public virtual IEnumerator GetEnumerator() { return Iterators.Flatten(Iterators.Map(_classes, new _IFunction4_26(this))); } private sealed class _IFunction4_26 : IFunction4 { public _IFunction4_26(ReflectionTestSuiteBuilder _enclosing) { this._enclosing = _enclosing; } public object Apply(object arg) { Type klass = (Type)arg; try { return this._enclosing.FromClass(klass); } catch (Exception e) { return new FailingTest(klass.FullName, e); } } private readonly ReflectionTestSuiteBuilder _enclosing; } /// /// Can be overriden in inherited classes to inject new fixtures into /// the context. /// /// /// Can be overriden in inherited classes to inject new fixtures into /// the context. /// /// /// protected virtual object WithContext(IClosure4 closure) { return closure.Run(); } /// protected virtual IEnumerator FromClass(Type clazz) { if (typeof(IClassLevelFixtureTest).IsAssignableFrom(clazz)) { return Iterators.Iterate(new ClassLevelFixtureTestSuite[] { new ClassLevelFixtureTestSuite (clazz, new _IClosure4_52(this, clazz)) }); } return (IEnumerator)WithContext(new _IClosure4_63(this, clazz)); } private sealed class _IClosure4_52 : IClosure4 { public _IClosure4_52(ReflectionTestSuiteBuilder _enclosing, Type clazz) { this._enclosing = _enclosing; this.clazz = clazz; } public object Run() { return (IEnumerator)this._enclosing.WithContext(new _IClosure4_54(this, clazz)); } private sealed class _IClosure4_54 : IClosure4 { public _IClosure4_54(_IClosure4_52 _enclosing, Type clazz) { this._enclosing = _enclosing; this.clazz = clazz; } public object Run() { return new ContextfulIterator(this._enclosing._enclosing.SuiteFor(clazz)); } private readonly _IClosure4_52 _enclosing; private readonly Type clazz; } private readonly ReflectionTestSuiteBuilder _enclosing; private readonly Type clazz; } private sealed class _IClosure4_63 : IClosure4 { public _IClosure4_63(ReflectionTestSuiteBuilder _enclosing, Type clazz) { this._enclosing = _enclosing; this.clazz = clazz; } public object Run() { return new ContextfulIterator(this._enclosing.SuiteFor(clazz)); } private readonly ReflectionTestSuiteBuilder _enclosing; private readonly Type clazz; } private IEnumerator SuiteFor(Type clazz) { if (!IsApplicable(clazz)) { TestPlatform.EmitWarning("DISABLED: " + clazz.FullName); return Iterators.EmptyIterator; } if (typeof(ITestSuiteBuilder).IsAssignableFrom(clazz)) { return ((ITestSuiteBuilder)NewInstance(clazz)).GetEnumerator(); } if (typeof(ITest).IsAssignableFrom(clazz)) { return Iterators.SingletonIterator(NewInstance(clazz)); } ValidateTestClass(clazz); return FromMethods(clazz); } private void ValidateTestClass(Type clazz) { if (!(typeof(ITestCase).IsAssignableFrom(clazz))) { throw new ArgumentException(string.Empty + clazz + " is not marked as " + typeof( ITestCase)); } } protected virtual bool IsApplicable(Type clazz) { return clazz != null; } // just removing the 'parameter not used' warning private IEnumerator FromMethods(Type clazz) { return Iterators.Map(clazz.GetMethods(), new _IFunction4_96(this, clazz)); } private sealed class _IFunction4_96 : IFunction4 { public _IFunction4_96(ReflectionTestSuiteBuilder _enclosing, Type clazz) { this._enclosing = _enclosing; this.clazz = clazz; } public object Apply(object arg) { MethodInfo method = (MethodInfo)arg; if (!this._enclosing.IsTestMethod(method)) { this._enclosing.EmitWarningOnIgnoredTestMethod(clazz, method); return Iterators.Skip; } return this._enclosing.FromMethod(clazz, method); } private readonly ReflectionTestSuiteBuilder _enclosing; private readonly Type clazz; } private void EmitWarningOnIgnoredTestMethod(Type clazz, MethodInfo method) { if (!StartsWithIgnoreCase(method.Name, "_test")) { return; } TestPlatform.EmitWarning("IGNORED: " + CreateTest(NewInstance(clazz), method).Label ()); } protected virtual bool IsTestMethod(MethodInfo method) { return HasTestPrefix(method) && TestPlatform.IsPublic(method) && !TestPlatform.IsStatic (method) && !TestPlatform.HasParameters(method); } private bool HasTestPrefix(MethodInfo method) { return StartsWithIgnoreCase(method.Name, "test"); } protected virtual bool StartsWithIgnoreCase(string s, string prefix) { return s.ToUpper().StartsWith(prefix.ToUpper()); } protected virtual object NewInstance(Type clazz) { try { return System.Activator.CreateInstance(clazz); } catch (Exception e) { throw new TestException("Failed to instantiate " + clazz, e); } } protected virtual ITest CreateTest(object instance, MethodInfo method) { return new TestMethod(instance, method); } protected ITest FromMethod(Type clazz, MethodInfo method) { return new ContextfulTest(new _ITestFactory_143(this, clazz, method)); } private sealed class _ITestFactory_143 : ITestFactory { public _ITestFactory_143(ReflectionTestSuiteBuilder _enclosing, Type clazz, MethodInfo method) { this._enclosing = _enclosing; this.clazz = clazz; this.method = method; } public ITest NewInstance() { return this._enclosing.CreateTest(this._enclosing.NewInstance(clazz), method); } private readonly ReflectionTestSuiteBuilder _enclosing; private readonly Type clazz; private readonly MethodInfo method; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/OpaqueTestSuiteBase.cs000644 001750 001750 00000005167 11520622622 027663 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public abstract class OpaqueTestSuiteBase : ITest { private IClosure4 _tests; public OpaqueTestSuiteBase(IClosure4 tests) { _tests = tests; } public virtual void Run() { ITestExecutor executor = ((ITestExecutor)Environments.My(typeof(ITestExecutor))); IEnumerator tests = ((IEnumerator)_tests.Run()); try { SuiteSetUp(); while (tests.MoveNext()) { executor.Execute(((ITest)tests.Current)); } SuiteTearDown(); } catch (Exception exc) { executor.Fail(this, exc); } } public virtual bool IsLeafTest() { return false; } protected virtual IClosure4 Tests() { return _tests; } public virtual ITest Transmogrify(IFunction4 fun) { return Transmogrified(new _IClosure4_38(this, fun)); } private sealed class _IClosure4_38 : IClosure4 { public _IClosure4_38(OpaqueTestSuiteBase _enclosing, IFunction4 fun) { this._enclosing = _enclosing; this.fun = fun; } public object Run() { return Iterators.Map(((IEnumerator)this._enclosing.Tests().Run()), new _IFunction4_40 (fun)); } private sealed class _IFunction4_40 : IFunction4 { public _IFunction4_40(IFunction4 fun) { this.fun = fun; } public object Apply(object test) { return ((ITest)fun.Apply(((ITest)test))); } private readonly IFunction4 fun; } private readonly OpaqueTestSuiteBase _enclosing; private readonly IFunction4 fun; } protected abstract Db4oUnit.OpaqueTestSuiteBase Transmogrified(IClosure4 tests); /// protected abstract void SuiteSetUp(); /// protected abstract void SuiteTearDown(); public abstract string Label(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/000755 001750 001750 00000000000 11520622070 024523 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/CompositeTestListenerTestCase.cs000644 001750 001750 00000006022 11520622622 033021 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Mocking; using Db4oUnit.Tests; namespace Db4oUnit.Tests { public class CompositeTestListenerTestCase : ITestCase { internal sealed class ListenerRecorder : ITestListener { private readonly MethodCallRecorder _recorder; private readonly string _label; public ListenerRecorder(string label, MethodCallRecorder recorder) { _label = label; _recorder = recorder; } public void RunFinished() { Record("runFinished"); } public void RunStarted() { Record("runStarted"); } public void TestFailed(ITest test, Exception failure) { Record("testFailed", new object[] { test, failure }); } public void TestStarted(ITest test) { Record("testStarted", new object[] { test }); } public void Failure(string msg, Exception failure) { Record("failure", new object[] { msg, failure }); } private void Record(string name) { Record(name, new object[0]); } private void Record(string name, object[] args) { _recorder.Record(new MethodCall(_label + "." + name, args)); } } public virtual void Test() { MethodCallRecorder recorder = new MethodCallRecorder(); CompositeTestListener listener = new CompositeTestListener(new CompositeTestListenerTestCase.ListenerRecorder ("first", recorder), new CompositeTestListenerTestCase.ListenerRecorder("second" , recorder)); RunsGreen test = new RunsGreen(); Exception failure = new Exception(); listener.RunStarted(); listener.TestStarted(test); listener.TestFailed(test, failure); listener.RunFinished(); recorder.Verify(new MethodCall[] { Call("first.runStarted"), Call("second.runStarted" ), Call("first.testStarted", test), Call("second.testStarted", test), Call("first.testFailed" , test, failure), Call("second.testFailed", test, failure), Call("first.runFinished" ), Call("second.runFinished") }); } private MethodCall Call(string method, object arg0, Exception arg1) { return new MethodCall(method, new object[] { arg0, arg1 }); } private MethodCall Call(string method, object arg) { return new MethodCall(method, new object[] { arg }); } private MethodCall Call(string method) { return new MethodCall(method, new object[] { }); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/OpaqueTestSuiteFailureTestCase.cs000644 001750 001750 00000006477 11520622622 033143 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class OpaqueTestSuiteFailureTestCase : ITestCase { public virtual void TestFailOnSetup() { BooleanByRef tearDownCalled = new BooleanByRef(); TestResult result = new TestResult(); new TestRunner(Iterators.Iterable(new OpaqueTestSuiteFailureTestCase.FailingTestSuite [] { new OpaqueTestSuiteFailureTestCase.FailingTestSuite(true, false, tearDownCalled ) })).Run(result); Assert.AreEqual(0, result.TestCount); Assert.AreEqual(1, result.Failures.Count); Assert.IsFalse(tearDownCalled.value); } public virtual void TestFailOnTearDown() { BooleanByRef tearDownCalled = new BooleanByRef(); TestResult result = new TestResult(); new TestRunner(Iterators.Iterable(new OpaqueTestSuiteFailureTestCase.FailingTestSuite [] { new OpaqueTestSuiteFailureTestCase.FailingTestSuite(false, true, tearDownCalled ) })).Run(result); Assert.AreEqual(1, result.TestCount); Assert.AreEqual(2, result.Failures.Count); Assert.IsTrue(tearDownCalled.value); } public class FailingTestSuite : OpaqueTestSuiteBase { private bool _failOnSetUp; private bool _failOnTeardown; private BooleanByRef _tearDownCalled; public FailingTestSuite(bool failOnSetup, bool failOnTeardown, BooleanByRef tearDownCalled ) : this(failOnSetup, failOnTeardown, tearDownCalled, new _IClosure4_34()) { } private sealed class _IClosure4_34 : IClosure4 { public _IClosure4_34() { } public object Run() { return Iterators.Iterate(new FailingTest[] { new FailingTest("fail", new AssertionException ("fail")) }); } } private FailingTestSuite(bool failOnSetup, bool failOnTeardown, BooleanByRef tearDownCalled , IClosure4 tests) : base(tests) { _failOnSetUp = failOnSetup; _failOnTeardown = failOnTeardown; _tearDownCalled = tearDownCalled; } /// protected override void SuiteSetUp() { if (_failOnSetUp) { Assert.Fail(); } } /// protected override void SuiteTearDown() { _tearDownCalled.value = true; if (_failOnTeardown) { Assert.Fail(); } } protected override OpaqueTestSuiteBase Transmogrified(IClosure4 tests) { return new OpaqueTestSuiteFailureTestCase.FailingTestSuite(_failOnSetUp, _failOnTeardown , _tearDownCalled, tests); } public override string Label() { return GetType().FullName; } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/TestLifeCycleTestCase.cs000644 001750 001750 00000002665 11520622622 031221 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Tests { public class TestLifeCycleTestCase : ITestCase { public virtual void TestLifeCycle() { ByRef tearDownCalled = ByRef.NewInstance(false); RunsLifeCycle._tearDownCalled.With(tearDownCalled, new _IRunnable_11()); Assert.IsTrue((((bool)tearDownCalled.value))); } private sealed class _IRunnable_11 : IRunnable { public _IRunnable_11() { } public void Run() { IEnumerator tests = new ReflectionTestSuiteBuilder(typeof(RunsLifeCycle)).GetEnumerator (); ITest test = (ITest)Iterators.Next(tests); FrameworkTestCase.RunTestAndExpect(test, 1); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/ReflectionTestSuiteBuilderTestCase.cs000644 001750 001750 00000005663 11520622622 033776 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class ReflectionTestSuiteBuilderTestCase : ITestCase { private sealed class ExcludingReflectionTestSuiteBuilder : ReflectionTestSuiteBuilder { public ExcludingReflectionTestSuiteBuilder(Type[] classes) : base(classes) { } protected override bool IsApplicable(Type clazz) { return clazz != typeof(ReflectionTestSuiteBuilderTestCase.NotAccepted); } } public class NonTestFixture { } public virtual void TestUnmarkedTestFixture() { ReflectionTestSuiteBuilder builder = new ReflectionTestSuiteBuilder(typeof(ReflectionTestSuiteBuilderTestCase.NonTestFixture )); AssertFailingTestCase(typeof(ArgumentException), builder); } public class Accepted : ITestCase { public virtual void Test() { } } public class NotAccepted : ITestCase { public virtual void Test() { } } public virtual void TestNotAcceptedFixture() { ReflectionTestSuiteBuilder builder = new ReflectionTestSuiteBuilderTestCase.ExcludingReflectionTestSuiteBuilder (new Type[] { typeof(ReflectionTestSuiteBuilderTestCase.Accepted), typeof(ReflectionTestSuiteBuilderTestCase.NotAccepted ) }); Assert.AreEqual(1, Iterators.Size(builder.GetEnumerator())); } public class ConstructorThrows : ITestCase { public static readonly Exception Error = new Exception("no way"); public ConstructorThrows() { throw Error; } public virtual void Test1() { } public virtual void Test2() { } } public virtual void TestConstructorFailuresAppearAsFailedTestCases() { ReflectionTestSuiteBuilder builder = new ReflectionTestSuiteBuilder(typeof(ReflectionTestSuiteBuilderTestCase.ConstructorThrows )); Assert.AreEqual(2, Iterators.ToArray(builder.GetEnumerator()).Length); } private Exception AssertFailingTestCase(Type expectedError, ReflectionTestSuiteBuilder builder) { IEnumerator tests = builder.GetEnumerator(); FailingTest test = (FailingTest)Iterators.Next(tests); Assert.AreSame(expectedError, test.Error().GetType()); return test.Error(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/TestRunnerTestCase.cs000644 001750 001750 00000006322 11520622622 030625 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Mocking; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class TestRunnerTestCase : ITestCase { internal static readonly Exception FailureException = new Exception(); public virtual void TestRun() { RunsGreen greenTest = new RunsGreen(); RunsRed redTest = new RunsRed(FailureException); IEnumerable tests = Iterators.Iterable(new object[] { greenTest, redTest }); MethodCallRecorder recorder = new MethodCallRecorder(); ITestListener listener = new _ITestListener_23(recorder); new TestRunner(tests).Run(listener); recorder.Verify(new MethodCall[] { new MethodCall("runStarted", new object[] { } ), new MethodCall("testStarted", new object[] { greenTest }), new MethodCall("testStarted" , new object[] { redTest }), new MethodCall("testFailed", new object[] { redTest , FailureException }), new MethodCall("runFinished", new object[] { }) }); } private sealed class _ITestListener_23 : ITestListener { public _ITestListener_23(MethodCallRecorder recorder) { this.recorder = recorder; } public void TestStarted(ITest test) { recorder.Record(new MethodCall("testStarted", new object[] { test })); } public void TestFailed(ITest test, Exception failure) { recorder.Record(new MethodCall("testFailed", new object[] { test, failure })); } public void RunStarted() { recorder.Record(new MethodCall("runStarted", new object[] { })); } public void RunFinished() { recorder.Record(new MethodCall("runFinished", new object[] { })); } public void Failure(string msg, Exception failure) { recorder.Record(new MethodCall("failure", new object[] { msg, failure })); } private readonly MethodCallRecorder recorder; } public virtual void TestRunWithException() { ITest test = new _ITest_58(); //$NON-NLS-1$ IEnumerable tests = Iterators.Iterable(new object[] { test }); TestResult result = new TestResult(); new TestRunner(tests).Run(result); Assert.AreEqual(1, result.Failures.Count); } private sealed class _ITest_58 : ITest { public _ITest_58() { } public string Label() { return "Test"; } public void Run() { Assert.AreEqual(0, 1); } public bool IsLeafTest() { return true; } public ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/FrameworkTestCase.cs000644 001750 001750 00000004332 11520622622 030450 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class FrameworkTestCase : ITestCase { public static readonly Exception Exception = new Exception(); public virtual void TestRunsGreen() { TestResult result = new TestResult(); new TestRunner(Iterators.SingletonIterable(new RunsGreen())).Run(result); Assert.IsTrue(result.Failures.Count == 0, "not green"); } public virtual void TestRunsRed() { TestResult result = new TestResult(); new TestRunner(Iterators.SingletonIterable(new RunsRed(Exception))).Run(result); Assert.IsTrue(result.Failures.Count == 1, "not red"); } public static void RunTestAndExpect(ITest test, int expFailures) { RunTestAndExpect(test, expFailures, true); } public static void RunTestAndExpect(ITest test, int expFailures, bool checkException ) { RunTestAndExpect(Iterators.SingletonIterable(test), expFailures, checkException); } public static void RunTestAndExpect(IEnumerable tests, int expFailures, bool checkException ) { TestResult result = new TestResult(); new TestRunner(tests).Run(result); if (expFailures != result.Failures.Count) { Assert.Fail(result.Failures.ToString()); } if (checkException) { for (IEnumerator iter = result.Failures.GetEnumerator(); iter.MoveNext(); ) { TestFailure failure = (TestFailure)iter.Current; Assert.AreEqual(Exception, failure.Reason); } } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/RunsLifeCycle.cs000644 001750 001750 00000002754 11520622622 027574 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class RunsLifeCycle : ITestCase, ITestLifeCycle { public static DynamicVariable _tearDownCalled = DynamicVariable.NewInstance(); private bool _setupCalled = false; public virtual void SetUp() { _setupCalled = true; } public virtual void TearDown() { TearDownCalled().value = true; } public virtual bool SetupCalled() { return _setupCalled; } /// public virtual void TestMethod() { Assert.IsTrue(_setupCalled); Assert.IsTrue(!(((bool)TearDownCalled().value))); throw FrameworkTestCase.Exception; } private ByRef TearDownCalled() { return ((ByRef)_tearDownCalled.Value); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/ReinstantiatePerMethodTest.cs000644 001750 001750 00000001720 11520622622 032337 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit.Tests { public class ReinstantiatePerMethodTest : ITestCase { private int a = 0; public virtual void Test1() { Assert.AreEqual(0, a); a = 1; } public virtual void Test2() { Assert.AreEqual(0, a); a = 2; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/000755 001750 001750 00000000000 11520622066 026341 5ustar00directhexdirecthex000000 000000 src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/FixtureBasedTestSuiteTestCase.cs000644 001750 001750 00000016765 11520622622 034521 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Fixtures; using Db4oUnit.Mocking; using Db4oUnit.Tests.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests.Fixtures { public class FixtureBasedTestSuiteTestCase : ITestCase { internal static FixtureVariable RecorderFixture = FixtureVariable.NewInstance("recorder" ); internal static FixtureVariable Fixture1 = new FixtureVariable("f1"); internal static FixtureVariable Fixture2 = new FixtureVariable("f2"); public sealed class TestUnit : ITestCase { private readonly object fixture1 = Fixture1.Value; private readonly object fixture2 = Fixture2.Value; public void TestFoo() { Record("testFoo"); } public void TestBar() { Record("testBar"); } private void Record(string test) { Recorder().Record(new MethodCall(test, new object[] { fixture1, fixture2 })); } private MethodCallRecorder Recorder() { return ((MethodCallRecorder)RecorderFixture.Value); } } public virtual void Test() { MethodCallRecorder recorder = new MethodCallRecorder(); Run(new _FixtureBasedTestSuite_45(recorder)); // System.out.println(CodeGenerator.generateMethodCallArray(recorder)); recorder.Verify(new MethodCall[] { new MethodCall("testFoo", new object[] { "f11" , "f21" }), new MethodCall("testFoo", new object[] { "f11", "f22" }), new MethodCall ("testFoo", new object[] { "f12", "f21" }), new MethodCall("testFoo", new object [] { "f12", "f22" }), new MethodCall("testBar", new object[] { "f11", "f21" }), new MethodCall("testBar", new object[] { "f11", "f22" }), new MethodCall("testBar" , new object[] { "f12", "f21" }), new MethodCall("testBar", new object[] { "f12" , "f22" }) }); } private sealed class _FixtureBasedTestSuite_45 : FixtureBasedTestSuite { public _FixtureBasedTestSuite_45(MethodCallRecorder recorder) { this.recorder = recorder; } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .RecorderFixture, new object[] { recorder }), new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture1, new object[] { "f11", "f12" }), new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture2, new object[] { "f21", "f22" }) }; } public override Type[] TestUnits() { return new Type[] { typeof(FixtureBasedTestSuiteTestCase.TestUnit) }; } private readonly MethodCallRecorder recorder; } public virtual void TestCombinationToRun() { MethodCallRecorder recorder = new MethodCallRecorder(); Run(new _FixtureBasedTestSuite_78(recorder)); // System.out.println(CodeGenerator.generateMethodCallArray(recorder)); recorder.Verify(new MethodCall[] { new MethodCall("testFoo", new object[] { "f11" , "f22" }), new MethodCall("testBar", new object[] { "f11", "f22" }) }); } private sealed class _FixtureBasedTestSuite_78 : FixtureBasedTestSuite { public _FixtureBasedTestSuite_78(MethodCallRecorder recorder) { this.recorder = recorder; } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .RecorderFixture, new object[] { recorder }), new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture1, new object[] { "f11", "f12" }), new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture2, new object[] { "f21", "f22" }) }; } public override Type[] TestUnits() { return new Type[] { typeof(FixtureBasedTestSuiteTestCase.TestUnit) }; } public override int[] CombinationToRun() { return new int[] { 0, 0, 1 }; } private readonly MethodCallRecorder recorder; } public virtual void TestInvalidCombinationToRun() { Assert.Expect(typeof(AssertionException), new _ICodeBlock_107(this)); } private sealed class _ICodeBlock_107 : ICodeBlock { public _ICodeBlock_107(FixtureBasedTestSuiteTestCase _enclosing) { this._enclosing = _enclosing; } public void Run() { this._enclosing.RunInvalidCombination(); } private readonly FixtureBasedTestSuiteTestCase _enclosing; } private void RunInvalidCombination() { Run(new _FixtureBasedTestSuite_115()); } private sealed class _FixtureBasedTestSuite_115 : FixtureBasedTestSuite { public _FixtureBasedTestSuite_115() { } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture1, new object[] { "f11", "f12" }), new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture2, new object[] { "f21", "f22" }) }; } public override Type[] TestUnits() { return new Type[] { typeof(FixtureBasedTestSuiteTestCase.TestUnit) }; } public override int[] CombinationToRun() { return new int[] { 0 }; } } private void Run(FixtureBasedTestSuite suite) { TestResult result = new TestResult(); new TestRunner(suite).Run(result); if (result.Failures.Count > 0) { Assert.Fail(Iterators.ToString(result.Failures)); } } public virtual void TestLabel() { FixtureBasedTestSuite suite = new _FixtureBasedTestSuite_142(); IEnumerable labels = Iterators.Map(suite, new _IFunction4_154()); Iterator4Assert.AreEqual(new object[] { TestLabel("testFoo", 0, 0), TestLabel("testFoo" , 1, 0), TestLabel("testFoo", 0, 1), TestLabel("testFoo", 1, 1), TestLabel("testBar" , 0, 0), TestLabel("testBar", 1, 0), TestLabel("testBar", 0, 1), TestLabel("testBar" , 1, 1) }, labels.GetEnumerator()); } private sealed class _FixtureBasedTestSuite_142 : FixtureBasedTestSuite { public _FixtureBasedTestSuite_142() { } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture1, new object[] { "f11", "f12" }), new SimpleFixtureProvider(FixtureBasedTestSuiteTestCase .Fixture2, new object[] { "f21", "f22" }) }; } public override Type[] TestUnits() { return new Type[] { typeof(FixtureBasedTestSuiteTestCase.TestUnit) }; } } private sealed class _IFunction4_154 : IFunction4 { public _IFunction4_154() { } public object Apply(object arg) { return ((ITest)arg).Label(); } } private string TestLabel(string testMethod, int fixture1Index, int fixture2Index) { string prefix = "(f2[" + fixture1Index + "]) (f1[" + fixture2Index + "]) "; return prefix + typeof(FixtureBasedTestSuiteTestCase.TestUnit).FullName + "." + testMethod; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/AllTests.cs000644 001750 001750 00000002172 11520622622 030423 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Tests.Fixtures; namespace Db4oUnit.Tests.Fixtures { public class AllTests : ReflectionTestSuite { public static void Main(string[] args) { new ConsoleTestRunner(typeof(Db4oUnit.Tests.Fixtures.AllTests)).Run(); } protected override Type[] TestCases() { return new Type[] { typeof(FixtureBasedTestSuiteTestCase), typeof(FixtureContextTestCase ), typeof(Set4TestSuite) }; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/FixtureContextTestCase.cs000644 001750 001750 00000012520 11520622622 033315 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Fixtures; using Db4oUnit.Tests.Fixtures; using Sharpen.Lang; namespace Db4oUnit.Tests.Fixtures { public class FixtureContextTestCase : ITestCase { public sealed class ContextRef { public FixtureContext value; } public virtual void Test() { FixtureVariable f1 = new FixtureVariable(); FixtureVariable f2 = new FixtureVariable(); FixtureContextTestCase.ContextRef c1 = new FixtureContextTestCase.ContextRef(); FixtureContextTestCase.ContextRef c2 = new FixtureContextTestCase.ContextRef(); new FixtureContext().Run(new _IRunnable_19(this, f1, f2, c1, c2)); AssertNoValue(f1); AssertNoValue(f2); c1.value.Run(new _IRunnable_41(this, f1, f2)); c2.value.Run(new _IRunnable_48(this, f1, f2)); } private sealed class _IRunnable_19 : IRunnable { public _IRunnable_19(FixtureContextTestCase _enclosing, FixtureVariable f1, FixtureVariable f2, FixtureContextTestCase.ContextRef c1, FixtureContextTestCase.ContextRef c2) { this._enclosing = _enclosing; this.f1 = f1; this.f2 = f2; this.c1 = c1; this.c2 = c2; } public void Run() { f1.With("foo", new _IRunnable_21(this, f1, f2, c1, c2)); } private sealed class _IRunnable_21 : IRunnable { public _IRunnable_21(_IRunnable_19 _enclosing, FixtureVariable f1, FixtureVariable f2, FixtureContextTestCase.ContextRef c1, FixtureContextTestCase.ContextRef c2) { this._enclosing = _enclosing; this.f1 = f1; this.f2 = f2; this.c1 = c1; this.c2 = c2; } public void Run() { this._enclosing._enclosing.AssertValue("foo", f1); this._enclosing._enclosing.AssertNoValue(f2); c1.value = FixtureContext.Current; f2.With("bar", new _IRunnable_26(this, f1, f2, c2)); } private sealed class _IRunnable_26 : IRunnable { public _IRunnable_26(_IRunnable_21 _enclosing, FixtureVariable f1, FixtureVariable f2, FixtureContextTestCase.ContextRef c2) { this._enclosing = _enclosing; this.f1 = f1; this.f2 = f2; this.c2 = c2; } public void Run() { this._enclosing._enclosing._enclosing.AssertValue("foo", f1); this._enclosing._enclosing._enclosing.AssertValue("bar", f2); c2.value = FixtureContext.Current; } private readonly _IRunnable_21 _enclosing; private readonly FixtureVariable f1; private readonly FixtureVariable f2; private readonly FixtureContextTestCase.ContextRef c2; } private readonly _IRunnable_19 _enclosing; private readonly FixtureVariable f1; private readonly FixtureVariable f2; private readonly FixtureContextTestCase.ContextRef c1; private readonly FixtureContextTestCase.ContextRef c2; } private readonly FixtureContextTestCase _enclosing; private readonly FixtureVariable f1; private readonly FixtureVariable f2; private readonly FixtureContextTestCase.ContextRef c1; private readonly FixtureContextTestCase.ContextRef c2; } private sealed class _IRunnable_41 : IRunnable { public _IRunnable_41(FixtureContextTestCase _enclosing, FixtureVariable f1, FixtureVariable f2) { this._enclosing = _enclosing; this.f1 = f1; this.f2 = f2; } public void Run() { this._enclosing.AssertValue("foo", f1); this._enclosing.AssertNoValue(f2); } private readonly FixtureContextTestCase _enclosing; private readonly FixtureVariable f1; private readonly FixtureVariable f2; } private sealed class _IRunnable_48 : IRunnable { public _IRunnable_48(FixtureContextTestCase _enclosing, FixtureVariable f1, FixtureVariable f2) { this._enclosing = _enclosing; this.f1 = f1; this.f2 = f2; } public void Run() { this._enclosing.AssertValue("foo", f1); this._enclosing.AssertValue("bar", f2); } private readonly FixtureContextTestCase _enclosing; private readonly FixtureVariable f1; private readonly FixtureVariable f2; } private void AssertNoValue(FixtureVariable f1) { Assert.Expect(typeof(InvalidOperationException), new _ICodeBlock_57(f1)); } private sealed class _ICodeBlock_57 : ICodeBlock { public _ICodeBlock_57(FixtureVariable f1) { this.f1 = f1; } public void Run() { this.Use(f1.Value); } private void Use(object value) { } private readonly FixtureVariable f1; } private void AssertValue(string expected, FixtureVariable fixture) { Assert.AreEqual(expected, fixture.Value); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/Set4TestUnit.cs000644 001750 001750 00000002774 11520622622 031217 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Fixtures; using Db4oUnit.Tests.Fixtures; namespace Db4oUnit.Tests.Fixtures { public class Set4TestUnit : ITestLifeCycle { private readonly ISet4 subject = (ISet4)SubjectFixtureProvider.Value(); private readonly object[] data = MultiValueFixtureProvider.Value(); public virtual void SetUp() { for (int i = 0; i < data.Length; ++i) { object element = data[i]; subject.Add(element); } } public virtual void TestSize() { Assert.AreEqual(data.Length, subject.Size()); } public virtual void TestContains() { for (int i = 0; i < data.Length; ++i) { object element = data[i]; Assert.IsTrue(subject.Contains(element)); } } /// public virtual void TearDown() { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/HashtableSet4.cs000644 001750 001750 00000002131 11520622622 031316 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Tests.Fixtures; namespace Db4oUnit.Tests.Fixtures { public class HashtableSet4 : ISet4 { internal Hashtable _table = new Hashtable(); public virtual void Add(object value) { _table[value] = value; } public virtual bool Contains(object value) { return _table.Contains(value); } public virtual int Size() { return _table.Count; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/Set4TestSuite.cs000644 001750 001750 00000003461 11520622622 031363 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Fixtures; using Db4oUnit.Tests.Fixtures; namespace Db4oUnit.Tests.Fixtures { public class Set4TestSuite : FixtureBasedTestSuite { public static void Main(string[] args) { new ConsoleTestRunner(typeof(Set4TestSuite)).Run(); } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SubjectFixtureProvider(new IDeferred4[] { new _IDeferred4_17(), new _IDeferred4_21() }), new MultiValueFixtureProvider(new object [][] { new object[] { }, new object[] { "foo", "bar", "baz" }, new object[] { "foo" }, new object[] { 42, -1 } }) }; } private sealed class _IDeferred4_17 : IDeferred4 { public _IDeferred4_17() { } public object Value() { return new CollectionSet4(); } } private sealed class _IDeferred4_21 : IDeferred4 { public _IDeferred4_21() { } public object Value() { return new HashtableSet4(); } } public override Type[] TestUnits() { return new Type[] { typeof(Set4TestUnit) }; } // Iterable4TestUnit.class, } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/CollectionSet4.cs000644 001750 001750 00000002131 11520622622 031516 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Tests.Fixtures; namespace Db4oUnit.Tests.Fixtures { public class CollectionSet4 : ISet4 { private ArrayList _vector = new ArrayList(); public virtual void Add(object value) { _vector.Add(value); } public virtual bool Contains(object value) { return _vector.Contains(value); } public virtual int Size() { return _vector.Count; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/ISet4.cs000644 001750 001750 00000001477 11520622622 027627 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Tests.Fixtures { public interface ISet4 { void Add(object value); bool Contains(object value); int Size(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Fixtures/Iterable4TestUnit.cs000644 001750 001750 00000002421 11520622622 032200 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4oUnit.Fixtures; namespace Db4oUnit.Tests.Fixtures { public class Iterable4TestUnit : ITestCase { private readonly IEnumerable subject = (IEnumerable)SubjectFixtureProvider.Value( ); private readonly object[] data = MultiValueFixtureProvider.Value(); public virtual void TestElements() { IEnumerator elements = subject.GetEnumerator(); for (int i = 0; i < data.Length; ++i) { Assert.IsTrue(elements.MoveNext()); Assert.AreEqual(data[i], elements.Current); } Assert.IsFalse(elements.MoveNext()); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/AllTests.cs000644 001750 001750 00000003033 11520622622 026607 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Tests; namespace Db4oUnit.Tests { public class AllTests : ReflectionTestSuite { protected override Type[] TestCases() { return new Type[] { typeof(AssertTestCase), typeof(ClassLevelFixtureTestTestCase) , typeof(CompositeTestListenerTestCase), typeof(ExceptionInTearDownDoesNotShadowTestCase ), typeof(FrameworkTestCase), typeof(OpaqueTestSuiteFailureTestCase), typeof(OpaqueTestSuiteTestCase ), typeof(ReflectionTestSuiteBuilderTestCase), typeof(ReinstantiatePerMethodTest ), typeof(TestExceptionWithInnerCause), typeof(TestLifeCycleTestCase), typeof(TestRunnerTestCase ), typeof(Db4oUnit.Tests.Data.AllTests), typeof(Db4oUnit.Tests.Fixtures.AllTests ) }; } public static void Main(string[] args) { new ConsoleTestRunner(typeof(Db4oUnit.Tests.AllTests)).Run(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/AssertTestCase.cs000644 001750 001750 00000004752 11520622622 027762 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit.Tests { public class AssertTestCase : ITestCase { public virtual void TestAreEqual() { Assert.AreEqual(true, true); Assert.AreEqual(42, 42); Assert.AreEqual(42, 42); Assert.AreEqual(null, null); ExpectFailure(new _ICodeBlock_14()); ExpectFailure(new _ICodeBlock_19()); ExpectFailure(new _ICodeBlock_24()); ExpectFailure(new _ICodeBlock_29()); } private sealed class _ICodeBlock_14 : ICodeBlock { public _ICodeBlock_14() { } /// public void Run() { Assert.AreEqual(true, false); } } private sealed class _ICodeBlock_19 : ICodeBlock { public _ICodeBlock_19() { } /// public void Run() { Assert.AreEqual(42, 43); } } private sealed class _ICodeBlock_24 : ICodeBlock { public _ICodeBlock_24() { } /// public void Run() { Assert.AreEqual(new object(), new object()); } } private sealed class _ICodeBlock_29 : ICodeBlock { public _ICodeBlock_29() { } /// public void Run() { Assert.AreEqual(null, new object()); } } public virtual void TestAreSame() { ExpectFailure(new _ICodeBlock_37()); Assert.AreSame(this, this); } private sealed class _ICodeBlock_37 : ICodeBlock { public _ICodeBlock_37() { } /// public void Run() { Assert.AreSame(new object(), new object()); } } private void ExpectFailure(ICodeBlock block) { Assert.Expect(typeof(AssertionException), block); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Data/000755 001750 001750 00000000000 11520622070 025374 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Data/AllTests.cs000644 001750 001750 00000002046 11520622622 027463 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Tests.Data; namespace Db4oUnit.Tests.Data { public class AllTests : ReflectionTestSuite { public static void Main(string[] args) { new Db4oUnit.Tests.Data.AllTests().Run(); } protected override Type[] TestCases() { return new Type[] { typeof(GeneratorsTestCase), typeof(StreamsTestCase) }; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Data/GeneratorsTestCase.cs000644 001750 001750 00000004651 11520622622 031501 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Data; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests.Data { public class GeneratorsTestCase : ITestCase { public virtual void TestArbitraryIntegerValues() { CheckArbitraryValuesOf(typeof(int)); } public virtual void TestArbitraryStringValues() { CheckArbitraryValuesOf(typeof(string)); Iterator4Assert.All(Generators.ArbitraryValuesOf(typeof(string)), new _IPredicate4_16 ()); } private sealed class _IPredicate4_16 : IPredicate4 { public _IPredicate4_16() { } public bool Match(object candidate) { return this.IsValidString((string)candidate); } private bool IsValidString(string s) { for (int i = 0; i < s.Length; ++i) { char ch = s[i]; if (!char.IsLetterOrDigit(ch) && !char.IsWhiteSpace(ch) && ch != '_') { return false; } } return true; } } private void CheckArbitraryValuesOf(Type expectedType) { IEnumerable values = Generators.ArbitraryValuesOf(expectedType); Assert.IsTrue(values.GetEnumerator().MoveNext()); Iterator4Assert.AreInstanceOf(expectedType, values); } public virtual void TestTake() { string[] values = new string[] { "1", "2", "3" }; IEnumerable source = Iterators.Iterable(values); AssertTake(new object[0], 0, source); AssertTake(new object[] { "1" }, 1, source); AssertTake(new object[] { "1", "2" }, 2, source); AssertTake(values, 3, source); AssertTake(values, 4, source); } private void AssertTake(object[] expected, int count, IEnumerable source) { Iterator4Assert.AreEqual(expected, Generators.Take(count, source).GetEnumerator() ); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/Data/StreamsTestCase.cs000644 001750 001750 00000002736 11520622622 031010 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests.Data { public class StreamsTestCase : ITestCase { public virtual void TestSeries() { Collection4 calls = new Collection4(); IEnumerator series = Iterators.Series(string.Empty, new _IFunction4_11(calls)).GetEnumerator (); Assert.IsTrue(series.MoveNext()); Assert.IsTrue(series.MoveNext()); Iterator4Assert.AreEqual(new object[] { string.Empty, "*" }, calls.GetEnumerator( )); } private sealed class _IFunction4_11 : IFunction4 { public _IFunction4_11(Collection4 calls) { this.calls = calls; } public object Apply(object value) { calls.Add(value); return value + "*"; } private readonly Collection4 calls; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/OpaqueTestSuiteTestCase.cs000644 001750 001750 00000011205 11520622622 031614 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class OpaqueTestSuiteTestCase : ITestCase { private const int NumTests = 3; public virtual void TestAllSucceed() { AssertTestRuns(new int[] { }); } public virtual void TestSingleFailure() { AssertTestRuns(new int[] { NumTests / 2 }); } public virtual void TestAllFail() { int[] failingIndices = new int[NumTests]; for (int i = 0; i < NumTests; i++) { failingIndices[i] = i; } AssertTestRuns(failingIndices); } private void AssertTestRuns(int[] failingIndices) { IntByRef counter = new IntByRef(); TestResult result = new _TestResult_29(); new TestRunner(Iterators.Iterable(new OpaqueTestSuiteTestCase.SimpleTestSuite[] { new OpaqueTestSuiteTestCase.SimpleTestSuite(counter, NumTests, failingIndices) } )).Run(result); Assert.AreEqual(NumTests, result.TestCount); Assert.AreEqual(failingIndices.Length, result.Failures.Count); Assert.AreEqual(NumTests + 2, counter.value); } private sealed class _TestResult_29 : TestResult { public _TestResult_29() { } public override void TestStarted(ITest test) { base.TestStarted(test); Assert.IsInstanceOf(typeof(OpaqueTestSuiteTestCase.CountingTest), test); } } public class SimpleTestSuite : OpaqueTestSuiteBase { private IntByRef _counter; private int _numTests; public SimpleTestSuite(IntByRef counter, int numTests, int[] failingIndices) : this (counter, numTests, new _IClosure4_47(counter, numTests, failingIndices)) { } private sealed class _IClosure4_47 : IClosure4 { public _IClosure4_47(IntByRef counter, int numTests, int[] failingIndices) { this.counter = counter; this.numTests = numTests; this.failingIndices = failingIndices; } public object Run() { return Iterators.Iterate(OpaqueTestSuiteTestCase.SimpleTestSuite.Tests(counter, numTests , failingIndices)); } private readonly IntByRef counter; private readonly int numTests; private readonly int[] failingIndices; } private SimpleTestSuite(IntByRef counter, int numTests, IClosure4 tests) : base(tests ) { _counter = counter; _numTests = numTests; } /// protected override void SuiteSetUp() { Assert.AreEqual(0, _counter.value); _counter.value++; } /// protected override void SuiteTearDown() { Assert.AreEqual(_numTests + 1, _counter.value); _counter.value++; } public override string Label() { return GetType().FullName; } private static ITest[] Tests(IntByRef counter, int numTests, int[] failingIndices ) { ITest[] tests = new ITest[numTests]; for (int i = 0; i < numTests; i++) { tests[i] = new OpaqueTestSuiteTestCase.CountingTest(counter, i + 1, Arrays4.IndexOf (failingIndices, i) >= 0); } return tests; } protected override OpaqueTestSuiteBase Transmogrified(IClosure4 tests) { return new OpaqueTestSuiteTestCase.SimpleTestSuite(_counter, _numTests, tests); } } public class CountingTest : ITest { private IntByRef _counter; private int _idx; private bool _fail; public CountingTest(IntByRef counter, int idx, bool fail) { _counter = counter; _idx = idx; _fail = fail; } public virtual bool IsLeafTest() { return true; } public virtual string Label() { return GetType().FullName; } public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } public virtual void Run() { Assert.AreEqual(_idx, _counter.value); _counter.value++; if (_fail) { Assert.Fail(); } } } } } src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/ExceptionInTearDownDoesNotShadowTestCase.cs000644 001750 001750 00000004402 11520622622 034765 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { public class ExceptionInTearDownDoesNotShadowTestCase : ITestCase { public static readonly string InTestMessage = "in test"; public static readonly string InTeardownMessage = "in teardown"; public class RunsWithExceptions : ITestLifeCycle { public virtual void SetUp() { } public virtual void TearDown() { throw new Exception(InTeardownMessage); } /// public virtual void TestMethod() { throw FrameworkTestCase.Exception; } } public class RunsWithExceptionInTearDown : ITestLifeCycle { public virtual void SetUp() { } public virtual void TearDown() { throw FrameworkTestCase.Exception; } /// public virtual void TestMethod() { } } public virtual void TestExceptions() { IEnumerator tests = new ReflectionTestSuiteBuilder(typeof(ExceptionInTearDownDoesNotShadowTestCase.RunsWithExceptions )).GetEnumerator(); ITest test = (ITest)Iterators.Next(tests); FrameworkTestCase.RunTestAndExpect(test, 1); } public virtual void TestExceptionInTearDown() { IEnumerator tests = new ReflectionTestSuiteBuilder(typeof(ExceptionInTearDownDoesNotShadowTestCase.RunsWithExceptionInTearDown )).GetEnumerator(); ITest test = (ITest)Iterators.Next(tests); FrameworkTestCase.RunTestAndExpect(test, 1); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/ClassLevelFixtureTestTestCase.cs000644 001750 001750 00000003010 11520622622 032747 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Tests; namespace Db4oUnit.Tests { public class ClassLevelFixtureTestTestCase : ITestCase { private static int _count; public virtual void Test() { _count = 0; TestResult result = new TestResult(); new TestRunner(new ReflectionTestSuiteBuilder(typeof(ClassLevelFixtureTestTestCase.SimpleTestSuite ))).Run(result); Assert.AreEqual(3, _count); Assert.AreEqual(1, result.TestCount); Assert.AreEqual(0, result.Failures.Count); } public class SimpleTestSuite : IClassLevelFixtureTest { public static void ClassSetUp() { ClassLevelFixtureTestTestCase._count++; } public static void ClassTearDown() { ClassLevelFixtureTestTestCase._count++; } public virtual void Test() { ClassLevelFixtureTestTestCase._count++; } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/RunsRed.cs000644 001750 001750 00000001546 11520622622 026445 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit.Tests { internal class RunsRed : FailingTest { public RunsRed(Exception exception) : base("RunsRed", exception) { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/RunsGreen.cs000644 001750 001750 00000002073 11520622622 026767 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Tests { internal class RunsGreen : ITest { public virtual string Label() { return "RunsGreen"; } public virtual void Run() { } public virtual bool IsLeafTest() { return true; } public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Tests/TestExceptionWithInnerCause.cs000644 001750 001750 00000002027 11520622622 032465 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit.Tests { public class TestExceptionWithInnerCause : ITestCase { public virtual void TestDetailerMessage() { string message = "Detailed message"; TestException e = new TestException(message, new Exception("The reason!")); Assert.IsGreaterOrEqual(0, e.ToString().IndexOf(message)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/IClassLevelFixtureTest.cs000644 001750 001750 00000001422 11520622622 030327 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit { public interface IClassLevelFixtureTest : ITestCase { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ConsoleListener.cs000644 001750 001750 00000003313 11520622622 027063 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4oUnit; namespace Db4oUnit { public class ConsoleListener : ITestListener { private readonly TextWriter _writer; public ConsoleListener(TextWriter writer) { _writer = writer; } public virtual void RunFinished() { } public virtual void RunStarted() { } public virtual void TestFailed(ITest test, Exception failure) { PrintFailure(failure); } public virtual void TestStarted(ITest test) { Print(test.Label()); } private void PrintFailure(Exception failure) { if (failure == null) { Print("\t!"); } else { Print("\t! " + failure); } } private void Print(string message) { try { _writer.Write(message + TestPlatform.NewLine); _writer.Flush(); } catch (IOException x) { TestPlatform.PrintStackTrace(_writer, x); } } public virtual void Failure(string msg, Exception failure) { Print("\t ! " + msg); PrintFailure(failure); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestExecutor.cs000644 001750 001750 00000001524 11520622622 026524 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { public interface ITestExecutor { void Execute(ITest test); void Fail(ITest test, Exception exc); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestFactory.cs000644 001750 001750 00000001424 11520622622 026334 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit { public interface ITestFactory { ITest NewInstance(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Iterator4Assert.cs000644 001750 001750 00000005516 11520622622 027021 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public class Iterator4Assert { public static void AreEqual(IEnumerable expected, IEnumerable actual) { AreEqual(expected.GetEnumerator(), actual.GetEnumerator()); } public static void AreEqual(IEnumerator expected, IEnumerator actual) { if (null == expected) { Assert.IsNull(actual); return; } Assert.IsNotNull(actual); while (expected.MoveNext()) { AssertNext(expected.Current, actual); } if (actual.MoveNext()) { Unexpected(actual.Current); } } private static void Unexpected(object element) { Assert.Fail("Unexpected element: " + element); } public static void AssertNext(object expected, IEnumerator iterator) { Assert.IsTrue(iterator.MoveNext(), "'" + expected + "' expected."); Assert.AreEqual(expected, iterator.Current); } public static void AreEqual(object[] expected, IEnumerator iterator) { AreEqual(new ArrayIterator4(expected), iterator); } public static void SameContent(object[] expected, IEnumerator actual) { SameContent(new ArrayIterator4(expected), actual); } public static void SameContent(IEnumerator expected, IEnumerator actual) { Collection4 allExpected = new Collection4(expected); while (actual.MoveNext()) { object current = actual.Current; bool removed = allExpected.Remove(current); if (!removed) { Unexpected(current); } } Assert.IsTrue(allExpected.IsEmpty(), "Still missing: " + allExpected.ToString()); } public static void AreInstanceOf(Type expectedType, IEnumerable values) { for (IEnumerator i = values.GetEnumerator(); i.MoveNext(); ) { Assert.IsInstanceOf(expectedType, i.Current); } } public static void All(IEnumerable values, IPredicate4 condition) { IEnumerator iterator = values.GetEnumerator(); while (iterator.MoveNext()) { if (!condition.Match(iterator.Current)) { Assert.Fail("Condition does not hold for for value '" + iterator.Current + "'."); } } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/StringAssert.cs000644 001750 001750 00000001712 11520622622 026404 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit { public class StringAssert { public static void Contains(string expected, string actual) { if (actual.IndexOf(expected) >= 0) { return; } Assert.Fail("'" + actual + "' does not contain '" + expected + "'"); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Iterable4Assert.cs000644 001750 001750 00000001350 11520622622 026747 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { public class Iterable4Assert { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ClassLevelFixtureTestSuite.cs000644 001750 001750 00000003271 11520622622 031234 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; namespace Db4oUnit { public class ClassLevelFixtureTestSuite : OpaqueTestSuiteBase { public static readonly string TeardownMethodName = "classTearDown"; public static readonly string SetupMethodName = "classSetUp"; private readonly Type _clazz; public ClassLevelFixtureTestSuite(Type clazz, IClosure4 tests) : base(tests) { _clazz = clazz; } /// protected override void SuiteSetUp() { Reflection4.InvokeStatic(_clazz, SetupMethodName); } /// protected override void SuiteTearDown() { Reflection4.InvokeStatic(_clazz, TeardownMethodName); } public override string Label() { return _clazz.FullName; } protected override OpaqueTestSuiteBase Transmogrified(IClosure4 tests) { return new Db4oUnit.ClassLevelFixtureTestSuite(_clazz, tests); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ContextfulTest.cs000644 001750 001750 00000004425 11520622622 026753 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit { public class ContextfulTest : Contextful, ITest { private ITestFactory _factory; public ContextfulTest(ITestFactory factory) { _factory = factory; } public virtual string Label() { return (string)Run(new _IClosure4_18(this)); } private sealed class _IClosure4_18 : IClosure4 { public _IClosure4_18(ContextfulTest _enclosing) { this._enclosing = _enclosing; } public object Run() { return this._enclosing.TestInstance().Label(); } private readonly ContextfulTest _enclosing; } public virtual bool IsLeafTest() { return ((bool)Run(new _IClosure4_26(this))); } private sealed class _IClosure4_26 : IClosure4 { public _IClosure4_26(ContextfulTest _enclosing) { this._enclosing = _enclosing; } public object Run() { return this._enclosing.TestInstance().IsLeafTest(); } private readonly ContextfulTest _enclosing; } public virtual void Run() { Run(new _IRunnable_34(this)); } private sealed class _IRunnable_34 : IRunnable { public _IRunnable_34(ContextfulTest _enclosing) { this._enclosing = _enclosing; } public void Run() { this._enclosing.TestInstance().Run(); } private readonly ContextfulTest _enclosing; } private ITest TestInstance() { return _factory.NewInstance(); } public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/CompositeTestListener.cs000644 001750 001750 00000003241 11520622622 030263 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { public class CompositeTestListener : ITestListener { private readonly ITestListener _listener1; private readonly ITestListener _listener2; public CompositeTestListener(ITestListener listener1, ITestListener listener2) { _listener1 = listener1; _listener2 = listener2; } public virtual void RunFinished() { _listener1.RunFinished(); _listener2.RunFinished(); } public virtual void RunStarted() { _listener1.RunStarted(); _listener2.RunStarted(); } public virtual void TestFailed(ITest test, Exception failure) { _listener1.TestFailed(test, failure); _listener2.TestFailed(test, failure); } public virtual void TestStarted(ITest test) { _listener1.TestStarted(test); _listener2.TestStarted(test); } public virtual void Failure(string msg, Exception failure) { _listener1.Failure(msg, failure); _listener2.Failure(msg, failure); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/000755 001750 001750 00000000000 11520622070 025232 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/FixtureVariable.cs000644 001750 001750 00000003666 11520622622 030673 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Fixtures { public class FixtureVariable { public static Db4oUnit.Fixtures.FixtureVariable NewInstance(string label) { return new Db4oUnit.Fixtures.FixtureVariable(label); } private readonly string _label; public FixtureVariable() : this(string.Empty) { } public FixtureVariable(string label) { _label = label; } public virtual string Label { get { return _label; } } public override string ToString() { return _label; } public virtual object With(object value, IClosure4 closure) { return Inject(value).Run(closure); } public virtual void With(object value, IRunnable runnable) { Inject(value).Run(runnable); } private FixtureContext Inject(object value) { return CurrentContext().Add(this, value); } public virtual object Value { get { FixtureContext.Found found = CurrentContext().Get(this); if (null == found) { throw new InvalidOperationException(); } return (object)found.value; } } private FixtureContext CurrentContext() { return FixtureContext.Current; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/IDeferred4.cs000644 001750 001750 00000001403 11520622622 027477 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Fixtures { public interface IDeferred4 { object Value(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/MultiValueFixtureProvider.cs000644 001750 001750 00000002503 11520622622 032735 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Fixtures { public class MultiValueFixtureProvider : IFixtureProvider { public static object[] Value() { return (object[])_variable.Value; } private static readonly FixtureVariable _variable = new FixtureVariable("data"); private readonly object[][] _values; public MultiValueFixtureProvider(object[][] values) { _values = values; } public virtual FixtureVariable Variable() { return _variable; } public virtual IEnumerator GetEnumerator() { return Iterators.Iterate(_values); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/FixtureBasedTestSuite.cs000644 001750 001750 00000012704 11520622622 032027 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Fixtures { /// /// TODO: experiment with ParallelTestRunner that uses a thread pool to run tests in parallel /// TODO: FixtureProviders must accept the index of a specific fixture to run with (to make it easy to reproduce a failure) /// public abstract class FixtureBasedTestSuite : ITestSuiteBuilder { private static readonly int[] AllCombinations = null; public abstract Type[] TestUnits(); public abstract IFixtureProvider[] FixtureProviders(); public virtual int[] CombinationToRun() { return AllCombinations; } public virtual IEnumerator GetEnumerator() { IFixtureProvider[] providers = FixtureProviders(); IEnumerable decorators = FixtureDecoratorsFor(providers); IEnumerable testsXdecorators = Iterators.CrossProduct(new IEnumerable[] { Tests() , Iterators.CrossProduct(decorators) }); return Iterators.Map(testsXdecorators, new _IFunction4_35(this)).GetEnumerator(); } private sealed class _IFunction4_35 : IFunction4 { public _IFunction4_35(FixtureBasedTestSuite _enclosing) { this._enclosing = _enclosing; } public object Apply(object arg) { IEnumerator tuple = ((IEnumerable)arg).GetEnumerator(); ITest test = (ITest)Iterators.Next(tuple); IEnumerable decorators = (IEnumerable)Iterators.Next(tuple); return this._enclosing.Decorate(test, decorators.GetEnumerator()); } private readonly FixtureBasedTestSuite _enclosing; } private IEnumerable FixtureDecoratorsFor(IFixtureProvider[] providers) { int[] combination = CombinationToRun(); return combination == AllCombinations ? AllFixtureDecoratorsFor(providers) : CombinationFixtureDecoratorsFor (providers, combination); } private IEnumerable CombinationFixtureDecoratorsFor(IFixtureProvider[] providers, int[] combination) { Assert.AreEqual(providers.Length, combination.Length, "Number of indexes in combinationToRun should match number of providers" ); IEnumerable decorators = Iterators.Map(Iterators.Enumerate(Iterators.Iterable(providers )), new _IFunction4_54(combination)); return decorators; } private sealed class _IFunction4_54 : IFunction4 { public _IFunction4_54(int[] combination) { this.combination = combination; } public object Apply(object arg) { EnumerateIterator.Tuple providerTuple = (EnumerateIterator.Tuple)arg; IFixtureProvider provider = (IFixtureProvider)providerTuple.value; int wantedIndex = combination[providerTuple.index]; return Iterators.Map(Iterators.Enumerate(provider), new _IFunction4_59(wantedIndex , provider)); } private sealed class _IFunction4_59 : IFunction4 { public _IFunction4_59(int wantedIndex, IFixtureProvider provider) { this.wantedIndex = wantedIndex; this.provider = provider; } public object Apply(object arg) { EnumerateIterator.Tuple tuple = (EnumerateIterator.Tuple)arg; if (tuple.index != wantedIndex) { return Iterators.Skip; } return new FixtureDecorator(provider.Variable(), tuple.value, tuple.index); } private readonly int wantedIndex; private readonly IFixtureProvider provider; } private readonly int[] combination; } private IEnumerable AllFixtureDecoratorsFor(IFixtureProvider[] providers) { IEnumerable decorators = Iterators.Map(Iterators.Iterable(providers), new _IFunction4_74 ()); return decorators; } private sealed class _IFunction4_74 : IFunction4 { public _IFunction4_74() { } public object Apply(object arg) { IFixtureProvider provider = (IFixtureProvider)arg; return Iterators.Map(Iterators.Enumerate(provider), new _IFunction4_77(provider)); } private sealed class _IFunction4_77 : IFunction4 { public _IFunction4_77(IFixtureProvider provider) { this.provider = provider; } public object Apply(object arg) { EnumerateIterator.Tuple tuple = (EnumerateIterator.Tuple)arg; return new FixtureDecorator(provider.Variable(), tuple.value, tuple.index); } private readonly IFixtureProvider provider; } } private IEnumerable Tests() { Type[] units = TestUnits(); if (units == null || units.Length == 0) { throw new InvalidOperationException(GetType() + " has no TestUnits."); } return new ReflectionTestSuiteBuilder(units); } private ITest Decorate(ITest test, IEnumerator decorators) { while (decorators.MoveNext()) { test = ((ITestDecorator)decorators.Current).Decorate(test); } return test; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/TestWithFixture.cs000644 001750 001750 00000006033 11520622622 030710 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Fixtures { public sealed class TestWithFixture : ITest { private ITest _test; private readonly FixtureVariable _variable; private readonly object _value; private readonly string _fixtureLabel; public TestWithFixture(ITest test, FixtureVariable fixtureVariable, object fixtureValue ) : this(test, null, fixtureVariable, fixtureValue) { } public TestWithFixture(ITest test, string fixtureLabel, FixtureVariable fixtureVariable , object fixtureValue) { _test = test; _fixtureLabel = fixtureLabel; _variable = fixtureVariable; _value = fixtureValue; } public string Label() { ObjectByRef label = new ObjectByRef(); RunDecorated(new _IRunnable_26(this, label)); return (string)label.value; } private sealed class _IRunnable_26 : IRunnable { public _IRunnable_26(TestWithFixture _enclosing, ObjectByRef label) { this._enclosing = _enclosing; this.label = label; } public void Run() { label.value = "(" + this._enclosing.FixtureLabel() + ") " + this._enclosing._test .Label(); } private readonly TestWithFixture _enclosing; private readonly ObjectByRef label; } public void Run() { RunDecorated(_test); } public ITest Test() { return _test; } private void RunDecorated(IRunnable block) { _variable.With(Value(), block); } private object Value() { return _value is IDeferred4 ? ((IDeferred4)_value).Value() : _value; } private object FixtureLabel() { return (_fixtureLabel == null ? _value : _fixtureLabel); } public bool IsLeafTest() { BooleanByRef isLeaf = new BooleanByRef(); RunDecorated(new _IRunnable_58(this, isLeaf)); return isLeaf.value; } private sealed class _IRunnable_58 : IRunnable { public _IRunnable_58(TestWithFixture _enclosing, BooleanByRef isLeaf) { this._enclosing = _enclosing; this.isLeaf = isLeaf; } public void Run() { isLeaf.value = this._enclosing._test.IsLeafTest(); } private readonly TestWithFixture _enclosing; private readonly BooleanByRef isLeaf; } public ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/SubjectFixtureProvider.cs000644 001750 001750 00000002641 11520622622 032250 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Fixtures { public class SubjectFixtureProvider : IFixtureProvider { public static object Value() { return (object)_variable.Value; } private static readonly FixtureVariable _variable = new FixtureVariable("subject" ); private readonly IEnumerable _values; public SubjectFixtureProvider(IEnumerable values) { _values = values; } public SubjectFixtureProvider(object[] values) : this(Iterators.Iterable(values)) { } public virtual FixtureVariable Variable() { return _variable; } public virtual IEnumerator GetEnumerator() { return _values.GetEnumerator(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/ContextfulIterator.cs000644 001750 001750 00000004506 11520622622 031436 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Fixtures { public class ContextfulIterator : Contextful, IEnumerator { private readonly IEnumerator _delegate; public ContextfulIterator(IEnumerator delegate_) { _delegate = delegate_; } public virtual object Current { get { return Run(new _IClosure4_17(this)); } } private sealed class _IClosure4_17 : IClosure4 { public _IClosure4_17(ContextfulIterator _enclosing) { this._enclosing = _enclosing; } public object Run() { return this._enclosing._delegate.Current; } private readonly ContextfulIterator _enclosing; } public virtual bool MoveNext() { BooleanByRef result = new BooleanByRef(); Run(new _IRunnable_26(this, result)); return result.value; } private sealed class _IRunnable_26 : IRunnable { public _IRunnable_26(ContextfulIterator _enclosing, BooleanByRef result) { this._enclosing = _enclosing; this.result = result; } public void Run() { result.value = this._enclosing._delegate.MoveNext(); } private readonly ContextfulIterator _enclosing; private readonly BooleanByRef result; } public virtual void Reset() { Run(new _IRunnable_35(this)); } private sealed class _IRunnable_35 : IRunnable { public _IRunnable_35(ContextfulIterator _enclosing) { this._enclosing = _enclosing; } public void Run() { this._enclosing._delegate.Reset(); } private readonly ContextfulIterator _enclosing; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/SimpleFixtureProvider.cs000644 001750 001750 00000002362 11520622622 032102 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Fixtures { public class SimpleFixtureProvider : IFixtureProvider { private readonly FixtureVariable _variable; private readonly object[] _values; public SimpleFixtureProvider(FixtureVariable variable, object[] values) { _variable = variable; _values = values; } public virtual FixtureVariable Variable() { return _variable; } public virtual IEnumerator GetEnumerator() { return Iterators.Iterate(_values); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/EnvironmentProvider.cs000644 001750 001750 00000003424 11520622622 031606 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Fixtures { public class EnvironmentProvider : IFixtureProvider { private sealed class _FixtureVariable_7 : FixtureVariable { public _FixtureVariable_7() { } public override void With(object value, IRunnable runnable) { base.With(value, new _IRunnable_9(value, runnable)); } private sealed class _IRunnable_9 : IRunnable { public _IRunnable_9(object value, IRunnable runnable) { this.value = value; this.runnable = runnable; } public void Run() { Environments.RunWith((IEnvironment)value, runnable); } private readonly object value; private readonly IRunnable runnable; } } private readonly FixtureVariable _variable = new _FixtureVariable_7(); public virtual FixtureVariable Variable() { return _variable; } public virtual IEnumerator GetEnumerator() { return Iterators.SingletonIterator(Environments.NewConventionBasedEnvironment()); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/ILabeled.cs000644 001750 001750 00000001401 11520622622 027221 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Fixtures { public interface ILabeled { string Label(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/FixtureDecorator.cs000644 001750 001750 00000003717 11520622622 031065 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Fixtures { internal sealed class FixtureDecorator : ITestDecorator { private readonly object _fixture; private readonly FixtureVariable _provider; private readonly int _fixtureIndex; internal FixtureDecorator(FixtureVariable provider, object fixture, int fixtureIndex ) { _fixture = fixture; _provider = provider; _fixtureIndex = fixtureIndex; } public ITest Decorate(ITest test) { string label = Label(); return test.Transmogrify(new _IFunction4_22(this, label)); } private sealed class _IFunction4_22 : IFunction4 { public _IFunction4_22(FixtureDecorator _enclosing, string label) { this._enclosing = _enclosing; this.label = label; } public object Apply(object innerTest) { return new TestWithFixture(((ITest)innerTest), label, this._enclosing._provider, this._enclosing._fixture); } private readonly FixtureDecorator _enclosing; private readonly string label; } private string Label() { string label = _provider.Label + "[" + _fixtureIndex + "]"; if (_fixture is ILabeled) { label += ":" + ((ILabeled)_fixture).Label(); } return label; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/IFixtureProvider.cs000644 001750 001750 00000001532 11520622622 031037 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Fixtures; namespace Db4oUnit.Fixtures { public interface IFixtureProvider : IEnumerable { FixtureVariable Variable(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/Contextful.cs000644 001750 001750 00000002503 11520622622 027717 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Fixtures { public class Contextful { protected readonly FixtureContext _context; public Contextful() { _context = CurrentContext(); } protected virtual object Run(IClosure4 closure4) { return CombinedContext().Run(closure4); } protected virtual void Run(IRunnable runnable) { CombinedContext().Run(runnable); } private FixtureContext CombinedContext() { return CurrentContext().Combine(_context); } private FixtureContext CurrentContext() { return FixtureContext.Current; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/FixtureTestSuiteDescription.cs000644 001750 001750 00000002370 11520622622 033272 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Fixtures; namespace Db4oUnit.Fixtures { public class FixtureTestSuiteDescription : FixtureBasedTestSuite { private IFixtureProvider[] _providers; private Type[] _testUnits; public virtual void FixtureProviders(IFixtureProvider[] providers) { _providers = providers; } public virtual void TestUnits(Type[] testUnits) { _testUnits = testUnits; } public override IFixtureProvider[] FixtureProviders() { return _providers; } public override Type[] TestUnits() { return _testUnits; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/LabeledObject.cs000644 001750 001750 00000003067 11520622622 030251 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Fixtures; namespace Db4oUnit.Fixtures { public class LabeledObject : ILabeled { private readonly object _value; private readonly string _label; public LabeledObject(object value, string label) { _value = value; _label = label; } public LabeledObject(object value) : this(value, null) { } public virtual string Label() { if (_label == null) { return _value.ToString(); } return _label; } public virtual object Value() { return _value; } public static Db4oUnit.Fixtures.LabeledObject[] ForObjects(object[] values) { Db4oUnit.Fixtures.LabeledObject[] labeledObjects = new Db4oUnit.Fixtures.LabeledObject [values.Length]; for (int i = 0; i < values.Length; i++) { labeledObjects[i] = new Db4oUnit.Fixtures.LabeledObject(values[i]); } return labeledObjects; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Fixtures/FixtureContext.cs000644 001750 001750 00000006417 11520622622 030567 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit.Fixtures { /// /// Set of live /// FixtureVariable /// /value pairs. /// public class FixtureContext { private sealed class _DynamicVariable_13 : DynamicVariable { public _DynamicVariable_13() { this.EmptyContext = new FixtureContext(); } private readonly FixtureContext EmptyContext; protected override object DefaultValue() { return this.EmptyContext; } } private static readonly DynamicVariable _current = new _DynamicVariable_13(); public static FixtureContext Current { get { return (FixtureContext)_current.Value; } } public virtual object Run(IClosure4 closure) { return _current.With(this, closure); } public virtual void Run(IRunnable block) { _current.With(this, block); } internal class Found { public readonly object value; public Found(object value_) { value = value_; } } internal virtual FixtureContext.Found Get(FixtureVariable fixture) { return null; } public virtual FixtureContext Combine(FixtureContext parent) { return new _FixtureContext_49(this, parent); } private sealed class _FixtureContext_49 : FixtureContext { public _FixtureContext_49(FixtureContext _enclosing, FixtureContext parent) { this._enclosing = _enclosing; this.parent = parent; } internal override FixtureContext.Found Get(FixtureVariable fixture) { FixtureContext.Found found = this._enclosing.Get(fixture); if (null != found) { return found; } return parent.Get(fixture); } private readonly FixtureContext _enclosing; private readonly FixtureContext parent; } internal virtual FixtureContext Add(FixtureVariable fixture, object value) { return new _FixtureContext_59(this, fixture, value); } private sealed class _FixtureContext_59 : FixtureContext { public _FixtureContext_59(FixtureContext _enclosing, FixtureVariable fixture, object value) { this._enclosing = _enclosing; this.fixture = fixture; this.value = value; } internal override FixtureContext.Found Get(FixtureVariable key) { if (key == fixture) { return new FixtureContext.Found(value); } return this._enclosing.Get(key); } private readonly FixtureContext _enclosing; private readonly FixtureVariable fixture; private readonly object value; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TestFailureCollection.cs000644 001750 001750 00000004207 11520622622 030221 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using System.IO; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public class TestFailureCollection : Printable, IEnumerable { private readonly Collection4 _failures = new Collection4(); public virtual IEnumerator GetEnumerator() { return _failures.GetEnumerator(); } public virtual int Count { get { return _failures.Size(); } } public virtual void Add(TestFailure failure) { _failures.Add(failure); } /// public override void Print(TextWriter writer) { PrintSummary(writer); PrintDetails(writer); } /// private void PrintSummary(TextWriter writer) { int index = 1; IEnumerator e = GetEnumerator(); while (e.MoveNext()) { writer.Write(index.ToString()); writer.Write(") "); writer.Write(((TestFailure)e.Current).TestLabel); writer.Write(TestPlatform.NewLine); ++index; } } /// private void PrintDetails(TextWriter writer) { int index = 1; IEnumerator e = GetEnumerator(); while (e.MoveNext()) { writer.Write(TestPlatform.NewLine); writer.Write(index.ToString()); writer.Write(") "); ((Printable)e.Current).Print(writer); writer.Write(TestPlatform.NewLine); ++index; } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestCase.cs000644 001750 001750 00000001660 11520622622 025602 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { /// Marker interface for test cases. /// /// Marker interface for test cases. /// Required for IDE support and automatic test case /// discovery. /// public interface ITestCase { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestLifeCycle.cs000644 001750 001750 00000002063 11520622622 026564 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit { /// For test cases that need setUp/tearDown support. /// For test cases that need setUp/tearDown support. public interface ITestLifeCycle : ITestCase { /// void SetUp(); /// void TearDown(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Data/000755 001750 001750 00000000000 11520622064 024275 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Data/Streams.cs000644 001750 001750 00000006605 11520622622 026251 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit.Data; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Data { /// Factory for infinite sequences of values. /// Factory for infinite sequences of values. public class Streams { private static readonly Random random = new Random(); public static IEnumerable RandomIntegers() { return Iterators.Series(null, new _IFunction4_15()); } private sealed class _IFunction4_15 : IFunction4 { public _IFunction4_15() { } public object Apply(object arg) { return Streams.random.Next(); } } public static IEnumerable RandomNaturals(int ceiling) { return Iterators.Series(null, new _IFunction4_23(ceiling)); } private sealed class _IFunction4_23 : IFunction4 { public _IFunction4_23(int ceiling) { this.ceiling = ceiling; } public object Apply(object arg) { return Streams.random.Next(ceiling); } private readonly int ceiling; } public static IEnumerable RandomStrings() { int maxLength = 42; return Iterators.Map(RandomNaturals(maxLength), new _IFunction4_32()); } private sealed class _IFunction4_32 : IFunction4 { public _IFunction4_32() { } public object Apply(object arg) { int length = ((int)arg); return Streams.RandomString(length); } } private static string RandomString(int length) { return Iterators.Join(Generators.Take(length, PrintableCharacters()), string.Empty ); } public static IEnumerable PrintableCharacters() { return Iterators.Filter(RandomCharacters(), new _IPredicate4_45()); } private sealed class _IPredicate4_45 : IPredicate4 { public _IPredicate4_45() { } public bool Match(object candidate) { char character = (char)candidate; return this.IsPrintable(character); } private bool IsPrintable(char value) { if (value >= 'a' && value <= 'z') { return true; } if (value >= 'A' && value <= 'Z') { return true; } if (value >= '0' && value <= '9') { return true; } switch (value) { case '_': case ' ': case '\r': case '\n': { return true; } } return false; } } public static IEnumerable RandomCharacters() { char maxCharInclusive = 'z'; return Iterators.Map(RandomNaturals(1 + (int)maxCharInclusive), new _IFunction4_75 ()); } private sealed class _IFunction4_75 : IFunction4 { public _IFunction4_75() { } public object Apply(object value) { return (char)((int)value); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Data/Generators.cs000644 001750 001750 00000006110 11520622622 026733 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit.Data; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Data { public partial class Generators { public static IEnumerable ArbitraryValuesOf(Type type) { IEnumerable platformSpecific = PlatformSpecificArbitraryValuesOf(type); if (null != platformSpecific) { return platformSpecific; } if (type == typeof(int)) { return Take(10, Streams.RandomIntegers()); } if (type == typeof(string)) { return Take(10, Streams.RandomStrings()); } throw new NotImplementedException("No generator for type " + type); } internal static IEnumerable Trace(IEnumerable source) { return Iterators.Map(source, new _IFunction4_32()); } private sealed class _IFunction4_32 : IFunction4 { public _IFunction4_32() { } public object Apply(object value) { Sharpen.Runtime.Out.WriteLine(value); return value; } } public static IEnumerable Take(int count, IEnumerable source) { return new _IEnumerable_41(source, count); } private sealed class _IEnumerable_41 : IEnumerable { public _IEnumerable_41(IEnumerable source, int count) { this.source = source; this.count = count; } public IEnumerator GetEnumerator() { return new _IEnumerator_43(source, count); } private sealed class _IEnumerator_43 : IEnumerator { public _IEnumerator_43(IEnumerable source, int count) { this.source = source; this.count = count; this._taken = 0; this._delegate = source.GetEnumerator(); } private int _taken; private IEnumerator _delegate; public object Current { get { if (this._taken > count) { throw new InvalidOperationException(); } return this._delegate.Current; } } public bool MoveNext() { if (this._taken < count) { if (!this._delegate.MoveNext()) { this._taken = count; return false; } ++this._taken; return true; } return false; } public void Reset() { this._taken = 0; this._delegate = source.GetEnumerator(); } private readonly IEnumerable source; private readonly int count; } private readonly IEnumerable source; private readonly int count; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/IteratorAssert.cs000644 001750 001750 00000005225 11520622622 026732 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public class IteratorAssert { public static void AreEqual(IEnumerable expected, IEnumerable actual) { AreEqual(expected.GetEnumerator(), actual.GetEnumerator()); } public static void AreEqual(IEnumerator expected, IEnumerator actual) { if (null == expected) { Assert.IsNull(actual); return; } Assert.IsNotNull(actual); while (expected.MoveNext()) { Assert.IsTrue(actual.MoveNext()); Assert.AreEqual(expected.Current, actual.Current); } Assert.IsFalse(actual.MoveNext()); } public static void AreEqual(object[] expected, IEnumerator iterator) { ArrayList v = new ArrayList(); for (int i = 0; i < expected.Length; i++) { v.Add(expected[i]); } AreEqual(v.GetEnumerator(), iterator); } public static void SameContent(object[] expected, IEnumerable actual) { IList expectedList = new ArrayList(); for (int expectedObjectIndex = 0; expectedObjectIndex < expected.Length; ++expectedObjectIndex) { object expectedObject = expected[expectedObjectIndex]; expectedList.Add(expectedObject); } SameContent(expectedList, actual); } public static void SameContent(IEnumerable expected, IEnumerable actual) { SameContent(expected.GetEnumerator(), actual.GetEnumerator()); } public static void SameContent(IEnumerator expected, IEnumerator actual) { Collection4 allExpected = new Collection4(); while (expected.MoveNext()) { allExpected.Add(expected.Current); } while (actual.MoveNext()) { object current = actual.Current; bool removed = allExpected.Remove(current); if (!removed) { Unexpected(current); } } Assert.IsTrue(allExpected.IsEmpty(), allExpected.ToString()); } private static void Unexpected(object element) { Assert.Fail("Unexpected element: " + element); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Printable.cs000644 001750 001750 00000002066 11520622622 025677 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.IO; namespace Db4oUnit { public abstract class Printable { public override string ToString() { StringWriter writer = new StringWriter(); try { Print(writer); } catch (IOException) { } return writer.ToString(); } /// public abstract void Print(TextWriter writer); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TestResult.cs000644 001750 001750 00000004326 11520622622 026076 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4oUnit; using Db4oUnit.Util; namespace Db4oUnit { public class TestResult : Printable, ITestListener { private TestFailureCollection _failures = new TestFailureCollection(); private int _testCount = 0; private readonly StopWatch _watch = new StopWatch(); public TestResult() { } public virtual void TestStarted(ITest test) { ++_testCount; } public virtual void TestFailed(ITest test, Exception failure) { _failures.Add(new TestFailure(test.Label(), failure)); } public virtual void Failure(string msg, Exception failure) { } public virtual int TestCount { get { return _testCount; } } public virtual bool Green { get { return _failures.Count == 0; } } public virtual TestFailureCollection Failures { get { return _failures; } } /// public override void Print(TextWriter writer) { if (Green) { writer.Write("GREEN (" + _testCount + " tests) - " + ElapsedString() + TestPlatform .NewLine); return; } writer.Write("RED (" + _failures.Count + " out of " + _testCount + " tests failed) - " + ElapsedString() + TestPlatform.NewLine); _failures.Print(writer); } private string ElapsedString() { return _watch.ToString(); } public virtual void RunStarted() { _watch.Start(); } public virtual void RunFinished() { _watch.Stop(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ConsoleTestRunner.cs000644 001750 001750 00000005473 11520622622 027420 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.IO; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public class ConsoleTestRunner { private readonly IEnumerable _suite; private readonly bool _reportToFile; public ConsoleTestRunner(IEnumerator suite) : this(suite, true) { } public ConsoleTestRunner(IEnumerator suite, bool reportToFile) { if (null == suite) { throw new ArgumentException("suite"); } _suite = Iterators.Iterable(suite); _reportToFile = reportToFile; } public ConsoleTestRunner(IEnumerable suite) : this(suite, true) { } public ConsoleTestRunner(IEnumerable suite, bool reportToFile) { if (null == suite) { throw new ArgumentException("suite"); } _suite = suite; _reportToFile = reportToFile; } public ConsoleTestRunner(Type clazz) : this(new ReflectionTestSuiteBuilder(clazz) ) { } public virtual int Run() { return Run(TestPlatform.GetStdErr()); } protected virtual TestResult CreateTestResult() { return new TestResult(); } public virtual int Run(TextWriter writer) { TestResult result = CreateTestResult(); new TestRunner(_suite).Run(new CompositeTestListener(new ConsoleListener(writer), result)); ReportResult(result, writer); return result.Failures.Count; } private void Report(Exception x) { TestPlatform.PrintStackTrace(TestPlatform.GetStdErr(), x); } private void ReportResult(TestResult result, TextWriter writer) { if (_reportToFile) { ReportToTextFile(result); } Report(result, writer); } private void ReportToTextFile(TestResult result) { try { TextWriter writer = TestPlatform.OpenTextFile("db4ounit.log"); try { Report(result, writer); } finally { writer.Close(); } } catch (IOException e) { Report(e); } } private void Report(TestResult result, TextWriter writer) { try { result.Print(writer); writer.Flush(); } catch (IOException e) { Report(e); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/FailingTest.cs000644 001750 001750 00000002767 11520622622 026200 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { /// A test that always fails with a specific exception. /// A test that always fails with a specific exception. public class FailingTest : ITest { private readonly Exception _error; private readonly string _label; public FailingTest(string label, Exception error) { _label = label; _error = error; } public virtual string Label() { return _label; } public virtual Exception Error() { return _error; } public virtual void Run() { throw new TestException(_error); } public virtual bool IsLeafTest() { return true; } public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITest.cs000644 001750 001750 00000001615 11520622622 025006 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit { public interface ITest : IRunnable { string Label(); bool IsLeafTest(); ITest Transmogrify(IFunction4 fun); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ICodeBlock.cs000644 001750 001750 00000001455 11520622622 025716 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { public interface ICodeBlock { /// void Run(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TestDecorationAdapter.cs000644 001750 001750 00000002315 11520622622 030204 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o.Foundation; namespace Db4oUnit { public class TestDecorationAdapter : ITest { private readonly ITest _test; public TestDecorationAdapter(ITest test) { _test = test; } public virtual string Label() { return _test.Label(); } public virtual void Run() { _test.Run(); } public virtual bool IsLeafTest() { return _test.IsLeafTest(); } public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Assert.cs000644 001750 001750 00000017141 11520622622 025220 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { public sealed partial class Assert { public static Exception Expect(Type exception, ICodeBlock block) { Exception e = GetThrowable(block); AssertThrowable(exception, e, null); return e; } public static Exception Expect(Type exception, Type cause, ICodeBlock block) { return Expect(exception, cause, block, null); } public static Exception Expect(Type exception, Type cause, ICodeBlock block, string customMessage) { Exception e = GetThrowable(block); AssertThrowable(exception, e, customMessage); AssertThrowable(cause, e.InnerException, customMessage); return e; } private static void AssertThrowable(Type exception, Exception e, string customMessage ) { if (exception.IsInstanceOfType(e)) { return; } string messagePrefix = customMessage != null ? customMessage + ": " : string.Empty; string message = e == null ? "Exception '" + exception.FullName + "' expected" : "Expecting '" + exception.FullName + "' but got '" + e.GetType().FullName + "'"; Fail(messagePrefix + message, e); } private static Exception GetThrowable(ICodeBlock block) { try { block.Run(); } catch (Exception e) { return e; } return null; } public static void Fail() { Fail("FAILURE"); } public static void Fail(string msg) { throw new AssertionException(msg); } public static void Fail(string msg, Exception cause) { throw new AssertionException(msg, cause); } public static void IsTrue(bool condition) { IsTrue(condition, "FAILURE"); } public static void IsTrue(bool condition, string msg) { if (condition) { return; } Fail(msg); } public static void IsNull(object reference) { if (reference != null) { Fail(FailureMessage("null", reference)); } } public static void IsNull(object reference, string message) { if (reference != null) { Fail(message); } } public static void IsNotNull(object reference) { if (reference == null) { Fail(FailureMessage("not null", reference)); } } public static void IsNotNull(object reference, string message) { if (reference == null) { Fail(message); } } public static void AreEqual(bool expected, bool actual) { if (expected == actual) { return; } Fail(FailureMessage(expected, actual)); } public static void AreEqual(int expected, int actual) { AreEqual(expected, actual, null); } public static void AreEqual(int expected, int actual, string message) { if (expected == actual) { return; } Fail(FailureMessage(expected, actual, message)); } public static void AreEqual(double expected, double actual) { AreEqual(expected, actual, null); } public static void AreEqual(double expected, double actual, string message) { if (expected == actual) { return; } Fail(FailureMessage(expected, actual, message)); } public static void AreEqual(long expected, long actual) { if (expected == actual) { return; } Fail(FailureMessage(expected, actual)); } public static void AreEqual(object expected, object actual, string message) { if (Check.ObjectsAreEqual(expected, actual)) { return; } Fail(FailureMessage(expected, actual, message)); } public static void AreEqual(object expected, object actual) { AreEqual(expected, actual, null); } public static void AreSame(object expected, object actual) { if (expected == actual) { return; } Fail(FailureMessage(expected, actual)); } public static void AreNotSame(object unexpected, object actual) { if (unexpected != actual) { return; } Fail("Expecting not '" + unexpected + "'."); } private static string FailureMessage(object expected, object actual) { return FailureMessage(expected, actual, null); } private static string FailureMessage(object expected, object actual, string customMessage ) { return FailureMessage(expected, actual, string.Empty, customMessage); } private static string FailureMessage(object expected, object actual, string cmpOper , string customMessage) { return (customMessage == null ? string.Empty : customMessage + ": ") + "Expected " + cmpOper + "'" + expected + "' but was '" + actual + "'"; } private static string FailureMessage(long expected, long actual, string cmpOper, string customMessage) { return (customMessage == null ? string.Empty : customMessage + ": ") + "Expected " + cmpOper + "'" + expected + "' but was '" + actual + "'"; } public static void IsFalse(bool condition) { IsTrue(!condition); } public static void IsFalse(bool condition, string message) { IsTrue(!condition, message); } public static void IsInstanceOf(Type expectedClass, object actual) { IsTrue(expectedClass.IsInstanceOfType(actual), FailureMessage(expectedClass, actual == null ? null : actual.GetType())); } public static void IsGreater(long expected, long actual) { if (actual > expected) { return; } Fail(FailureMessage(expected, actual, "greater than ", null)); } public static void IsGreaterOrEqual(long expected, long actual) { if (actual >= expected) { return; } Fail(expected, actual, "greater than or equal to ", null); } public static void IsSmaller(long expected, long actual) { if (actual < expected) { return; } Fail(FailureMessage(expected, actual, "smaller than ", null)); } public static void IsSmallerOrEqual(long expected, long actual) { if (actual <= expected) { return; } Fail(expected, actual, "smaller than or equal to ", null); } private static void Fail(long expected, long actual, string @operator, string customMessage ) { Fail(FailureMessage(expected, actual, @operator, null)); } public static void AreNotEqual(long unexpected, long actual) { AreNotEqual(unexpected, actual, null); } public static void AreNotEqual(long unexpected, long actual, string customMessage ) { if (actual != unexpected) { return; } Fail(unexpected, actual, "not equal to ", customMessage); } public static void AreNotEqual(object unexpected, object actual) { if (!Check.ObjectsAreEqual(unexpected, actual)) { return; } Fail("Expecting not '" + unexpected + "'"); } public static void EqualsAndHashcode(object obj, object same, object other) { AreEqual(obj, obj); AreEqual(obj, same); AreNotEqual(obj, other); AreEqual(obj.GetHashCode(), same.GetHashCode()); AreEqual(same, obj); AreNotEqual(other, obj); AreNotEqual(obj, null); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ReflectionTestSuite.cs000644 001750 001750 00000003261 11520622622 027721 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; namespace Db4oUnit { /// Support for hierarchically chained test suites. /// /// Support for hierarchically chained test suites. /// In the topmost test package define an AllTests class which extends /// ReflectionTestSuite and returns all subpackage.AllTests classes as /// testCases. Example: /// package org.acme.tests; /// public class AllTests extends ReflectionTestSuite { /// protected Class[] testCases() { /// return new Class[] { /// org.acme.tests.subsystem1.AllTests.class, /// org.acme.tests.subsystem2.AllTests.class, /// }; /// } /// } /// public abstract class ReflectionTestSuite : ITestSuiteBuilder { public virtual IEnumerator GetEnumerator() { return new ReflectionTestSuiteBuilder(TestCases()).GetEnumerator(); } protected abstract Type[] TestCases(); public virtual int Run() { return new ConsoleTestRunner(GetEnumerator()).Run(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TearDownFailureException.cs000644 001750 001750 00000001711 11520622622 030665 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; namespace Db4oUnit { [System.Serializable] public class TearDownFailureException : TestException { private const long serialVersionUID = -5998743679496701084L; public TearDownFailureException(Exception cause) : base(cause) { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestSuiteBuilder.cs000644 001750 001750 00000001661 11520622622 027330 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; namespace Db4oUnit { /// Custom test suite builder interface. /// Custom test suite builder interface. public interface ITestSuiteBuilder : ITestCase, IEnumerable { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ITestDecorator.cs000644 001750 001750 00000001435 11520622622 026651 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit { public interface ITestDecorator { ITest Decorate(ITest test); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Mocking/000755 001750 001750 00000000000 11520622070 025010 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Mocking/CodeGenerator.cs000644 001750 001750 00000005243 11520622622 030067 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4oUnit.Mocking; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Mocking { public class CodeGenerator { /// /// Generates an array that can be used with /// MethodCallRecorder.Verify(db4ounit.mocking.MethodCall[]) /// /// . /// Example: /// MethodCallRecorder recorder = new MethodCallRecorder(); /// runTest(recorder); /// System.out.println(CodeGenerator.generateMethodCallArray(recorder)) /// /// MethodCall generator /// array string public static string GenerateMethodCallArray(IEnumerable calls) { IEnumerable callStrings = Iterators.Map(calls, new _IFunction4_23()); return Iterators.Join(callStrings.GetEnumerator(), "," + TestPlatform.NewLine); } private sealed class _IFunction4_23 : IFunction4 { public _IFunction4_23() { } public object Apply(object arg) { return CodeGenerator.GenerateMethodCall((MethodCall)arg); } } public static string GenerateValue(object value) { if (value == null) { return "null"; } if (value is string) { return "\"" + value + "\""; } if (value is object[]) { return GenerateArray((object[])value); } return value.ToString(); } public static string GenerateArray(object[] array) { IEnumerator values = Iterators.Map(Iterators.Iterate(array), new _IFunction4_45() ); return "new Object[] " + Iterators.Join(values, "{", "}", ", "); } private sealed class _IFunction4_45 : IFunction4 { public _IFunction4_45() { } public object Apply(object arg) { return CodeGenerator.GenerateValue(arg); } } public static string GenerateMethodCall(MethodCall call) { return "new MethodCall(\"" + call.methodName + "\", " + GenerateArray(call.args) + ")"; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Mocking/MethodCallRecorder.cs000644 001750 001750 00000003403 11520622622 031044 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4oUnit.Mocking; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Mocking { public class MethodCallRecorder : IEnumerable { private readonly Collection4 _calls = new Collection4(); public virtual IEnumerator GetEnumerator() { return _calls.GetEnumerator(); } public virtual void Record(MethodCall call) { _calls.Add(call); } public virtual void Reset() { _calls.Clear(); } /// Asserts that the method calls were the same as expectedCalls. /// /// Asserts that the method calls were the same as expectedCalls. /// Unfortunately we cannot call this method 'assert' because /// it's a keyword starting with java 1.5. /// /// public virtual void Verify(MethodCall[] expectedCalls) { Iterator4Assert.AreEqual(expectedCalls, GetEnumerator()); } public virtual void VerifyUnordered(MethodCall[] expectedCalls) { Iterator4Assert.SameContent(expectedCalls, GetEnumerator()); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/Mocking/MethodCall.cs000644 001750 001750 00000005440 11520622622 027361 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Mocking; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Mocking { public class MethodCall { private sealed class _object_9 : object { public _object_9() { } public override string ToString() { return "..."; } } public static readonly object IgnoredArgument = new _object_9(); public interface IArgumentCondition { void Verify(object argument); } public class Conditions { public static MethodCall.IArgumentCondition IsA(Type expectedClass) { return new _IArgumentCondition_21(expectedClass); } private sealed class _IArgumentCondition_21 : MethodCall.IArgumentCondition { public _IArgumentCondition_21(Type expectedClass) { this.expectedClass = expectedClass; } public void Verify(object argument) { Assert.IsInstanceOf(expectedClass, argument); } private readonly Type expectedClass; } } public readonly string methodName; public readonly object[] args; public MethodCall(string methodName, object[] args) { this.methodName = methodName; this.args = args; } public override string ToString() { return methodName + "(" + Iterators.Join(Iterators.Iterate(args), ", ") + ")"; } public override bool Equals(object obj) { if (null == obj) { return false; } if (GetType() != obj.GetType()) { return false; } MethodCall other = (MethodCall)obj; if (!methodName.Equals(other.methodName)) { return false; } if (args.Length != other.args.Length) { return false; } for (int i = 0; i < args.Length; ++i) { object expectedArg = args[i]; if (expectedArg == IgnoredArgument) { continue; } object actualArg = other.args[i]; if (expectedArg is MethodCall.IArgumentCondition) { ((MethodCall.IArgumentCondition)expectedArg).Verify(actualArg); continue; } if (!Check.ObjectsAreEqual(expectedArg, actualArg)) { return false; } } return true; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/ArrayAssert.cs000644 001750 001750 00000011735 11520622622 026222 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o.Foundation; using Sharpen; namespace Db4oUnit { public partial class ArrayAssert { public static void Contains(long[] array, long expected) { if (-1 != IndexOf(array, expected)) { return; } Assert.Fail("Expecting '" + expected + "'."); } public static void ContainsByIdentity(object[] array, object[] expected) { for (int i = 0; i < expected.Length; i++) { if (-1 == Arrays4.IndexOfIdentity(array, expected[i])) { Assert.Fail("Expecting contains '" + expected[i] + "'."); } } } public static void ContainsByEquality(object[] array, object[] expected) { for (int i = 0; i < expected.Length; i++) { if (-1 == Arrays4.IndexOfEquals(array, expected[i])) { Assert.Fail("Expecting contains '" + expected[i] + "'."); } } } public static void AreEqual(object[] expected, object[] actual) { AreEqualImpl(expected, actual); } public static void AreEqual(string[] expected, string[] actual) { // JDK 1.1 needs the conversion AreEqualImpl(StringArrayToObjectArray(expected), StringArrayToObjectArray(actual) ); } private static object[] StringArrayToObjectArray(string[] expected) { object[] expectedAsObject = new object[expected.Length]; System.Array.Copy(expected, 0, expectedAsObject, 0, expected.Length); return expectedAsObject; } private static string IndexMessage(int i) { return "expected[" + i + "]"; } public static void AreEqual(byte[] expected, byte[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } public static void AreNotEqual(byte[] expected, byte[] actual) { Assert.AreNotSame(expected, actual); for (int i = 0; i < expected.Length; i++) { if (expected[i] != actual[i]) { return; } } Assert.IsTrue(false); } public static void AreEqual(int[] expected, int[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } public static void AreEqual(long[] expected, long[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } public static void AreEqual(float[] expected, float[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } public static void AreEqual(double[] expected, double[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } public static void AreEqual(char[] expected, char[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); } Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } private static int IndexOf(long[] array, long expected) { for (int i = 0; i < array.Length; ++i) { if (expected == array[i]) { return i; } } return -1; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit/Db4oUnit/TestRunner.cs000644 001750 001750 00000005366 11520622622 026076 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o.Foundation; using Sharpen.Lang; namespace Db4oUnit { public class TestRunner { public static DynamicVariable Executor = DynamicVariable.NewInstance(); private readonly IEnumerable _tests; public TestRunner(IEnumerable tests) { _tests = tests; } public virtual void Run(ITestListener listener) { listener.RunStarted(); ITestExecutor executor = new _ITestExecutor_19(this, listener); Environments.RunWith(Environments.NewClosedEnvironment(new object[] { executor }) , new _IRunnable_28(this, listener)); listener.RunFinished(); } private sealed class _ITestExecutor_19 : ITestExecutor { public _ITestExecutor_19(TestRunner _enclosing, ITestListener listener) { this._enclosing = _enclosing; this.listener = listener; } public void Execute(ITest test) { this._enclosing.RunTest(test, listener); } public void Fail(ITest test, Exception failure) { listener.TestFailed(test, failure); } private readonly TestRunner _enclosing; private readonly ITestListener listener; } private sealed class _IRunnable_28 : IRunnable { public _IRunnable_28(TestRunner _enclosing, ITestListener listener) { this._enclosing = _enclosing; this.listener = listener; } public void Run() { IEnumerator iterator = this._enclosing._tests.GetEnumerator(); while (iterator.MoveNext()) { this._enclosing.RunTest((ITest)iterator.Current, listener); } } private readonly TestRunner _enclosing; private readonly ITestListener listener; } private void RunTest(ITest test, ITestListener listener) { if (test.IsLeafTest()) { listener.TestStarted(test); } try { test.Run(); } catch (TestException x) { Exception reason = x.GetReason(); listener.TestFailed(test, reason == null ? x : reason); } catch (Exception failure) { listener.TestFailed(test, failure); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/000755 001750 001750 00000000000 11520622040 021624 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/000755 001750 001750 00000000000 11520622070 023257 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/AssertionException.cs000644 001750 001750 00000001675 11520622622 027450 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { public partial class AssertionException { #if !CF && !SILVERLIGHT public AssertionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } #endif } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/NullTextWriter.cs000644 001750 001750 00000001705 11520622622 026570 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Text; using System.IO; namespace Db4oUnit { class NullTextWriter : TextWriter { override public Encoding Encoding { get { return Encoding.UTF8; } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/Data/000755 001750 001750 00000000000 11520622066 024135 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/Data/Generators.cs000644 001750 001750 00000002274 11520622622 026600 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Data { public partial class Generators { public static IEnumerable PlatformSpecificArbitraryValuesOf(Type type) { if (IsNullable(type)) { return Iterators.Append(Generators.ArbitraryValuesOf(type.GetGenericArguments()[0]), null); } return null; } private static bool IsNullable(Type type) { return type.IsGenericType && typeof(Nullable<>) == type.GetGenericTypeDefinition(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/TestException.cs000644 001750 001750 00000002545 11520622622 026415 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4oUnit { public class TestException : Exception { public TestException(string message, Exception reason) : base(message, reason) { } public TestException(Exception reason) : base(reason.Message, reason) { } #if !CF && !SILVERLIGHT public TestException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } #endif public Exception GetReason() { return InnerException; } override public string ToString() { if (null != InnerException) return InnerException.ToString(); return base.ToString(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/TestPlatform.cs000644 001750 001750 00000003677 11520622622 026252 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { using System; using System.IO; using System.Reflection; public class TestPlatform { #if CF public static string NewLine = "\n"; #else public static string NewLine = Environment.NewLine; #endif // will be assigned from the outside on CF public static TextWriter Out; public static TextWriter Error; static TestPlatform() { Out = Console.Out; Error = Console.Error; } public static void PrintStackTrace(TextWriter writer, Exception e) { writer.Write(e); } public static TextWriter GetNullWriter() { return new NullTextWriter(); } public static TextWriter GetStdErr() { return Error; } public static void EmitWarning(string warning) { Out.WriteLine(warning); } public static bool IsStatic(MethodInfo method) { return method.IsStatic; } public static bool IsPublic(MethodInfo method) { return method.IsPublic; } public static bool HasParameters(MethodInfo method) { return method.GetParameters().Length > 0; } public static TextWriter OpenTextFile(string fname) { return new StreamWriter(fname); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/Util/000755 001750 001750 00000000000 11520622064 024177 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/Util/PlatformInformation.cs000644 001750 001750 00000001553 11520622622 030524 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Util { public class PlatformInformation { public static bool IsJava() { return false; } public static bool IsDotNet() { return true; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/Util/StopWatch.cs000644 001750 001750 00000002237 11520622622 026446 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Util { public class StopWatch { private System.DateTime _started; private System.DateTime _finished; public StopWatch() { } public virtual void Start() { _started = System.DateTime.Now; } public virtual void Stop() { _finished = System.DateTime.Now; } public virtual System.TimeSpan Elapsed() { return _finished - _started; } public override string ToString() { return Elapsed().ToString(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/Assert.cs000644 001750 001750 00000002775 11520622622 025065 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4oUnit { public delegate void CodeBlock(); public partial class Assert { public static Exception Expect(System.Type exception, CodeBlock block) { return Assert.Expect(exception, new DelegateCodeBlock(block)); } public static Exception Expect(CodeBlock block) where TException : Exception { return Assert.Expect(typeof(TException), block); } private class DelegateCodeBlock : ICodeBlock { private readonly CodeBlock _block; public DelegateCodeBlock(CodeBlock block) { _block = block; } public void Run() { _block(); } } public static void InRange(double value, double from, double to) { Assert.IsTrue(value >= from && value <= to, string.Format("'{0}' not in range '{1}'..'{2}'", value, from, to)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/native/Db4oUnit/ArrayAssert.cs000644 001750 001750 00000002444 11520622622 026055 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit { public partial class ArrayAssert { public static void AreEqual(T[] expected, T[] actual) { AreEqualImpl(expected, actual); } static void AreEqualImpl(T[] expected, T[] actual) { if (expected == actual) { return; } if (expected == null || actual == null) { Assert.AreSame(expected, actual); return; } Assert.AreEqual(expected.Length, actual.Length); Assert.AreSame(expected.GetType(), actual.GetType()); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i], IndexMessage(i)); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit-Silverlight-2010.csproj000644 001750 001750 00000024173 11520622060 026073 0ustar00directhexdirecthex000000 000000 v3.5 true ../db4objects.snk Debug AnyCPU 9.0.30729 2.0 {C74364D8-A04A-4CF9-801D-D1811D49E72A} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4oUnit Db4oUnit v4.0 false true true true ../db4objects.snk Silverlight $(TargetFrameworkVersion) 3.5 true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2010 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit-2008.csproj000644 001750 001750 00000022524 11520622052 023607 0ustar00directhexdirecthex000000 000000 9.0.30729 2.0 {8F82F8B0-95B6-4553-BDA8-BD9A954E682F} Debug AnyCPU Db4oUnit Library Db4oUnit OnBuildSuccess v3.5 512 true ../db4objects.snk bin\Debug\ false 285212672 false true TRACE;DEBUG;NET_3_5 4096 false 1591;1572;1573;1574;0419; false false false false 0 bin\Release\ false 285212672 false false TRACE;NET_3_5 4096 false 1591;1572;1573;1574;0419; true false false false 4 System {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Db4oUnit-2010.csproj000644 001750 001750 00000025541 11520622052 023602 0ustar00directhexdirecthex000000 000000 9.0.30729 2.0 {8F82F8B0-95B6-4553-BDA8-BD9A954E682F} Debug AnyCPU Db4oUnit Library Db4oUnit OnBuildSuccess v4.0 512 3.5 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../db4objects.snk bin\Debug\ false 285212672 false true TRACE;DEBUG;NET_3_5;NET_4_0 4096 false 1591;1572;1573;1574;0419; false false false false 0 bin\Release\ false 285212672 false false TRACE;NET_3_5;NET_4_0 4096 false 1591;1572;1573;1574;0419; true false false false 4 System False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2010 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Makefile000644 001750 001750 00000000140 11520622052 021774 0ustar00directhexdirecthex000000 000000 include ../include.mk TARGET = library ASSEMBLY = $(UNIT) REFERENCES = -r:$(OUTDIR)/$(CORE) db4o-8.0.184.15484+dfsg/src/Db4oUnit/Properties/000755 001750 001750 00000000000 11520622060 022474 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit/Properties/AssemblyInfo.cs000644 001750 001750 00000002563 11520622622 025430 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Security; [assembly: AssemblyTitle("db4o - database for objects")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyName("")] // attributes are automatically set by the build [assembly: AssemblyVersion("8.0.184.15484")] [assembly: AssemblyKeyFile("")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyDescription("Db4oUnit 8.0.184.15484 (.NET)")]db4o-8.0.184.15484+dfsg/src/drs/000755 001750 001750 00000000000 11520622056 017505 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/compatibility.net.html000644 001750 001750 00000002027 11520622042 024025 0ustar00directhexdirecthex000000 000000 COMPATIBILITY

db4o Replication System for .Net (Drs)
Compatibility

Drs is compatible with the following products:

.NET v 2.0 or later
db4o v @db4o.version.dotted@

db4o-8.0.184.15484+dfsg/src/drs/QuickStart/000755 001750 001750 00000000000 11520622070 021573 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/QuickStart/QuickStart-2008.sln000644 001750 001750 00000004643 11520622054 025003 0ustar00directhexdirecthex000000 000000  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickStart-2008", "QuickStart-2008.csproj", "{11C2A893-D0DA-48FC-82EC-12B3C3AC5F78}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-2008", "..\..\Db4objects.Db4o\Db4objects.Db4o-2008.csproj", "{600CD3BF-2ED2-4183-87F7-ADD78A968AE0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Drs-2008", "..\Db4objects.Drs\Db4objects.Drs-2008.csproj", "{B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CS-2008", "..\..\Db4objects.Db4o.CS\Db4objects.Db4o.CS-2008.csproj", "{9FA8178A-3E77-42C5-A252-6690EA9BA257}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {11C2A893-D0DA-48FC-82EC-12B3C3AC5F78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {11C2A893-D0DA-48FC-82EC-12B3C3AC5F78}.Debug|Any CPU.Build.0 = Debug|Any CPU {11C2A893-D0DA-48FC-82EC-12B3C3AC5F78}.Release|Any CPU.ActiveCfg = Release|Any CPU {11C2A893-D0DA-48FC-82EC-12B3C3AC5F78}.Release|Any CPU.Build.0 = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.Build.0 = Release|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Release|Any CPU.Build.0 = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.ActiveCfg = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/drs/QuickStart/Db4objects.Drs.Quickstart/000755 001750 001750 00000000000 11520622044 026437 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/QuickStart/Db4objects.Drs.Quickstart/Simple/000755 001750 001750 00000000000 11520622070 027667 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/QuickStart/Db4objects.Drs.Quickstart/Simple/Pilot.cs000644 001750 001750 00000001762 11520622640 031316 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Quickstart.Simple { public class Pilot { public string _name; public int _age; public Pilot() { } internal Pilot(string name, int age) { this._name = name; this._age = age; } public override string ToString() { return _name + "/" + _age; } } } db4o-8.0.184.15484+dfsg/src/drs/QuickStart/Db4objects.Drs.Quickstart/Simple/Simple.cs000644 001750 001750 00000014254 11520622640 031460 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Drs.Db4o; namespace Db4objects.Drs.Quickstart.Simple { public class Simple { public static void Main(string[] args) { new Db4objects.Drs.Quickstart.Simple.Simple().DoOneWayReplcation(); new Db4objects.Drs.Quickstart.Simple.Simple().DoBiDirectionalReplication(); new Db4objects.Drs.Quickstart.Simple.Simple().DoSelectiveReplication(); } public virtual void DoSelectiveReplication() { Db4objects.Db4o.IObjectContainer handheld = OpenDb(ConfigureDb4oForReplication(), "handheld.yap"); StoreSomePilots(handheld); Db4objects.Db4o.IObjectContainer desktop = OpenDb(ConfigureDb4oForReplication(), "desktop.yap"); DisplayContents("Selective Replication", "Before", handheld, desktop); Db4objects.Drs.IReplicationSession replication = Db4objects.Drs.Replication.Begin(ProviderFor(handheld), ProviderFor(desktop)); Db4objects.Db4o.IObjectSet changed = replication.ProviderA().ObjectsChangedSinceLastReplication (); while (changed.HasNext()) { Db4objects.Drs.Quickstart.Simple.Pilot p = (Db4objects.Drs.Quickstart.Simple.Pilot )changed.Next(); if (p._name.StartsWith("S")) { replication.Replicate(p); } } replication.Commit(); DisplayContents(string.Empty, "After", handheld, desktop); CloseDb(handheld); CloseDb(desktop); } private Db4oEmbeddedReplicationProvider ProviderFor(IObjectContainer handheld) { return new Db4oEmbeddedReplicationProvider(handheld); } private void DoBiDirectionalReplication() { Db4objects.Db4o.IObjectContainer handheld = OpenDb(ConfigureDb4oForReplication(), "handheld.yap"); StoreSomePilots(handheld); Db4objects.Db4o.IObjectContainer desktop = OpenDb(ConfigureDb4oForReplication(), "desktop.yap"); StoreSomeMorePilots(desktop); DisplayContents("Bi-Directional", "Before", handheld, desktop); Db4objects.Drs.IReplicationSession replication = Db4objects.Drs.Replication.Begin(ProviderFor(handheld), ProviderFor(desktop)); Db4objects.Db4o.IObjectSet changed = replication.ProviderA().ObjectsChangedSinceLastReplication (); while (changed.HasNext()) { replication.Replicate(changed.Next()); } changed = replication.ProviderB().ObjectsChangedSinceLastReplication(); while (changed.HasNext()) { replication.Replicate(changed.Next()); } replication.Commit(); DisplayContents(string.Empty, "After", handheld, desktop); CloseDb(handheld); CloseDb(desktop); } private void DisplayContents(string methodname, string pointintime, Db4objects.Db4o.IObjectContainer handheld, Db4objects.Db4o.IObjectContainer desktop) { if (methodname != string.Empty) { Sharpen.Runtime.Out.WriteLine(methodname + " Replication"); Sharpen.Runtime.Out.WriteLine(); } Sharpen.Runtime.Out.WriteLine(pointintime + " Replication"); Sharpen.Runtime.Out.WriteLine(); DisplayContentsOf("Contents of Handheld", handheld); DisplayContentsOf("Contents of Desktop", desktop); } private void StoreSomeMorePilots(Db4objects.Db4o.IObjectContainer db) { db.Store(new Db4objects.Drs.Quickstart.Simple.Pilot("Peter van der Merwe", 37)); db.Store(new Db4objects.Drs.Quickstart.Simple.Pilot("Albert Kwan", 30)); } private void DisplayContentsOf(string heading, Db4objects.Db4o.IObjectContainer db ) { Sharpen.Runtime.Out.WriteLine(heading); Sharpen.Runtime.Out.WriteLine(); Db4objects.Db4o.IObjectSet result = db.QueryByExample(new Db4objects.Drs.Quickstart.Simple.Pilot()); ListResult(result); } private void CloseDb(Db4objects.Db4o.IObjectContainer db) { db.Close(); } private Db4objects.Db4o.IObjectContainer OpenDb(IEmbeddedConfiguration config, string dbname) { new Sharpen.IO.File(dbname).Delete(); return Db4oEmbedded.OpenFile(config, dbname); } private IEmbeddedConfiguration ConfigureDb4oForReplication() { IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); configuration.File.GenerateUUIDs = ConfigScope.Globally; configuration.File.GenerateVersionNumbers = ConfigScope.Globally; return configuration; } private void DoOneWayReplcation() { Db4objects.Db4o.IObjectContainer handheld = OpenDb(ConfigureDb4oForReplication(), "handheld.yap"); StoreSomePilots(handheld); Db4objects.Db4o.IObjectContainer desktop = OpenDb(ConfigureDb4oForReplication(), "desktop.yap"); DisplayContents("One-way Replication", "Before", handheld, desktop); Db4objects.Drs.IReplicationSession replication = Db4objects.Drs.Replication.Begin (ProviderFor(handheld), ProviderFor(desktop)); Db4objects.Db4o.IObjectSet changed = replication.ProviderA().ObjectsChangedSinceLastReplication (); while (changed.HasNext()) { replication.Replicate(changed.Next()); } replication.Commit(); DisplayContents(string.Empty, "After", handheld, desktop); CloseDb(handheld); CloseDb(desktop); } private void StoreSomePilots(Db4objects.Db4o.IObjectContainer db) { db.Store(new Db4objects.Drs.Quickstart.Simple.Pilot("Scott Felton", 52)); db.Store(new Db4objects.Drs.Quickstart.Simple.Pilot("Frank Green", 45)); } public virtual void ListResult(Db4objects.Db4o.IObjectSet result) { while (result.HasNext()) { Sharpen.Runtime.Out.WriteLine(result.Next()); } Sharpen.Runtime.Out.WriteLine(); } } } db4o-8.0.184.15484+dfsg/src/drs/QuickStart/QuickStart-2008.csproj000644 001750 001750 00000011403 11520622060 025474 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {11C2A893-D0DA-48FC-82EC-12B3C3AC5F78} Exe Properties QuickStart QuickStart Db4objects.Drs.Quickstart.Simple.Simple 2.0 v3.5 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../../db4objects.snk true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 3.5 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6} Db4objects.Drs-2008 False .NET Framework Client Profile false False .NET Framework 2.0 %28x86%29 true False .NET Framework 3.0 %28x86%29 false False .NET Framework 3.5 false False .NET Framework 3.5 SP1 false db4o-8.0.184.15484+dfsg/src/drs/QuickStart/Properties/000755 001750 001750 00000000000 11520622070 023727 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/QuickStart/Properties/AssemblyInfo.cs000644 001750 001750 00000002413 11520622640 026654 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Db4objects.Drs.QuickStart")] [assembly: AssemblyDescription("QuickStart 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: AssemblyVersion("8.0.184.15484")] db4o-8.0.184.15484+dfsg/src/drs/drs.license.html000644 001750 001750 00000053003 11520622056 022605 0ustar00directhexdirecthex000000 000000 GNU GENERAL PUBLIC LICENSE

GNU GENERAL PUBLIC LICENSE

Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items -whatever suits your program.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.

db4o-8.0.184.15484+dfsg/src/drs/readme.html000644 001750 001750 00000003702 11520622056 021632 0ustar00directhexdirecthex000000 000000 README

Getting Started

For the fastest start with dRS please work through the tutorial, available in different formats in the following folder:

./docs/

Then you can look at an example replication in ./QuickStart project.

http://ant.apache.org/

Introductory online documentation is available at:

http://developer.db4o.com/Resources/view.aspx/Reference/Db4o_Replication_System_dRS

About this software

The software contained in this distribution is the open source db4o Replication System library "dRS" supplied by:

Versant Inc.
1900 South Norfolk Street
Suite 350
San Mateo, CA, 94403
USA

Make sure that you have downloaded the latest version from the db4objects website:
http://developer.db4o.com/files/

db4o Replication System may be used under the GNU General Public License, GPL.
You should have received a copy of the GPL with the download.

Your db4objects team.

db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/000755 001750 001750 00000000000 11520622070 022213 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs-2008.csproj000644 001750 001750 00000014076 11520622056 026552 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.21022 2.0 {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6} Library Properties Db4objects.Drs Db4objects.Drs v3.5 512 true ../../db4objects.snk true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 {9FA8178A-3E77-42C5-A252-6690EA9BA257} Db4objects.Db4o.CS-2008 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs-2008.sln000644 001750 001750 00000010752 11520622066 026044 0ustar00directhexdirecthex000000 000000  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Drs-2008", "Db4objects.Drs-2008.csproj", "{B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Drs.Tests-2008", "..\Db4objects.Drs.Tests\Db4objects.Drs.Tests-2008.csproj", "{C0BA12AD-54B4-43B0-A570-0299F6253AC7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CS-2008", "..\..\Db4objects.Db4o.CS\Db4objects.Db4o.CS-2008.csproj", "{9FA8178A-3E77-42C5-A252-6690EA9BA257}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-2008", "..\..\Db4objects.Db4o\Db4objects.Db4o-2008.csproj", "{600CD3BF-2ED2-4183-87F7-ADD78A968AE0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit-2008", "..\..\Db4oUnit\Db4oUnit-2008.csproj", "{8F82F8B0-95B6-4553-BDA8-BD9A954E682F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit.Extensions-2008", "..\..\Db4oUnit.Extensions\Db4oUnit.Extensions-2008.csproj", "{9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Optional-2008", "..\..\Db4objects.Db4o.Optional\Db4objects.Db4o.Optional-2008.csproj", "{E9588FE7-C19D-445E-BB53-AE539EA4F0E6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq-2008", "..\..\Db4objects.Db4o.Linq\Db4objects.Db4o.Linq-2008.csproj", "{23531440-0922-43EB-A483-6592FFC2F093}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Release|Any CPU.Build.0 = Release|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Release|Any CPU.Build.0 = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.ActiveCfg = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.Build.0 = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.Build.0 = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.Build.0 = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.Build.0 = Release|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {E9588FE7-C19D-445E-BB53-AE539EA4F0E6}.Release|Any CPU.Build.0 = Release|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Debug|Any CPU.Build.0 = Debug|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Release|Any CPU.ActiveCfg = Release|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/native/000755 001750 001750 00000000000 11520622056 023505 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/native/Db4objects.Drs/000755 001750 001750 00000000000 11520622064 026216 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/native/Db4objects.Drs/Inside/000755 001750 001750 00000000000 11520622056 027432 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/native/Db4objects.Drs/Inside/ReplicationPlatform.cs000644 001750 001750 00000011435 11520622640 033742 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Net; namespace Db4objects.Drs.Inside { /// /// Platform dependent code goes here to minimize manually /// converted code. /// public class ReplicationPlatform { interface ICollectionInitializer { void Clear(); void Add(object o); } public static void CopyCollectionState(object original, object destination, Db4objects.Drs.Inside.ICounterpartFinder counterpartFinder) { System.Collections.IEnumerable originalCollection = (System.Collections.IEnumerable )original; ICollectionInitializer destinationCollection = CollectionInitializerFor(destination); destinationCollection.Clear(); foreach (object element in originalCollection) { object counterpart = counterpartFinder.FindCounterpart(element); destinationCollection.Add(counterpart); } } private static ICollectionInitializer CollectionInitializerFor(object destination) { if (destination is IList) { return new ListInitializer((IList) destination); } Type collectionElementType = CollectionElementTypeFor(destination); if (collectionElementType != null) { Type genericProtocolType = typeof(GenericCollectionInitializer<>).MakeGenericType(collectionElementType); return (ICollectionInitializer) Activator.CreateInstance(genericProtocolType, destination); } throw new ArgumentException("Unknown collection: " + destination); } private static Type CollectionElementTypeFor(object destination) { foreach (Type interfaceType in destination.GetType().GetInterfaces()) { if (IsGenericCollection(interfaceType)) { return interfaceType.GetGenericArguments()[0]; } } return null; } private static bool IsGenericCollection(Type type) { return type.GetGenericTypeDefinition() == typeof(ICollection<>); } private class GenericCollectionInitializer : ICollectionInitializer { private ICollection _collection; public GenericCollectionInitializer(ICollection collection) { _collection = collection; } public void Clear() { _collection.Clear(); } public void Add(object o) { _collection.Add((T)o); } } private class ListInitializer : ICollectionInitializer { private readonly IList _list; public ListInitializer(IList list) { _list = list; } public void Clear() { _list.Clear(); } public void Add(object o) { _list.Add(o); } } public static System.Collections.ICollection EmptyCollectionClone(ICollectionSource source, System.Collections.ICollection original) { if (original is System.Collections.ArrayList) { return new System.Collections.ArrayList(original.Count); } try { return (System.Collections.ICollection) Activator.CreateInstance(original.GetType()); } catch (MissingMethodException x) { throw new ArgumentException(string.Format("Parameterless ctor required for type '{0}'", original.GetType()), x); } } public static bool IsValueType(object o) { if (null == o) return false; return o.GetType().IsValueType; } static readonly Type[] _nonGeneric = new Type[] { typeof(ArrayList), typeof(SortedList), typeof(Queue), typeof(Stack), }; static readonly Type[] _generic = new Type[] { typeof(List<>), typeof(LinkedList<>), typeof(Stack<>), }; internal static bool IsBuiltinCollectionClass(ReplicationReflector reflector, IReflectClass claxx) { Type type = NetReflector.ToNative(claxx); if (Contains(_nonGeneric, type)) return true; if (!type.IsGenericType) return false; if (Contains(_generic, type.GetGenericTypeDefinition())) return true; return false; } private static bool Contains(Type[] array, Type type) { return ((IList)array).Contains(type); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/native/Db4objects.Drs/Foundation/000755 001750 001750 00000000000 11520622066 030326 5ustar00directhexdirecthex000000 000000 src/drs/Db4objects.Drs/native/Db4objects.Drs/Foundation/ObjectSetCollection4Facade.cs000644 001750 001750 00000005371 11520622640 035650 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Foundation { public class ObjectSetCollection4Facade : ObjectSetAbstractFacade { internal Db4objects.Db4o.Foundation.Collection4 _delegate; private System.Collections.IEnumerator _currentIterator; enum Enumerator_Status { RESET, MOVING, EOF, }; Enumerator_Status _status; public ObjectSetCollection4Facade(Db4objects.Db4o.Foundation.Collection4 delegate_ ) { this._delegate = delegate_; } public override object Next() { object obj; if (HasNext()) { obj = CurrentIterator().Current; MoveNext(); return obj; } else { return null; } } public override bool HasNext() { if (_status == Enumerator_Status.RESET) { MoveNext(); } return _status != Enumerator_Status.EOF; } public override void Reset() { CurrentIterator().Reset(); _status = Enumerator_Status.RESET; } public override int Size() { return this._delegate.Size(); } public override bool Contains(object value) { return this._delegate.Contains(value); } private System.Collections.IEnumerator CurrentIterator() { if (_currentIterator == null) { _currentIterator = _delegate.GetEnumerator(); _status = Enumerator_Status.RESET; } return _currentIterator; } private void MoveNext() { if (CurrentIterator().MoveNext()) { _status = Enumerator_Status.MOVING; } else { _status = Enumerator_Status.EOF; } } } }src/drs/Db4objects.Drs/native/Db4objects.Drs/Foundation/ObjectSetAbstractFacade.cs000644 001750 001750 00000005200 11520622640 035223 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Ext; namespace Db4objects.Drs.Foundation { public abstract class ObjectSetAbstractFacade : Db4objects.Db4o.IObjectSet { public IExtObjectSet Ext() { throw new NotImplementedException(); } public virtual bool HasNext() { throw new NotImplementedException(); } public virtual object Next() { throw new NotImplementedException(); } public virtual void Reset() { throw new NotImplementedException(); } public virtual int Size() { throw new NotImplementedException(); } public int Add(object value) { throw new NotImplementedException(); } public virtual bool Contains(object value) { throw new NotImplementedException(); } public void Clear() { throw new NotImplementedException(); } public int IndexOf(object value) { throw new NotImplementedException(); } public void Insert(int index, object value) { throw new NotImplementedException(); } public void Remove(object value) { throw new NotImplementedException(); } public void RemoveAt(int index) { throw new NotImplementedException(); } public object this[int index] { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public bool IsReadOnly { get { throw new NotImplementedException(); } } public bool IsFixedSize { get { throw new NotImplementedException(); } } public void CopyTo(Array array, int index) { throw new NotImplementedException(); } public int Count { get { throw new NotImplementedException(); } } public object SyncRoot { get { throw new NotImplementedException(); } } public bool IsSynchronized { get { throw new NotImplementedException(); } } public IEnumerator GetEnumerator() { throw new NotImplementedException(); } } }db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/000755 001750 001750 00000000000 11520622070 024725 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/IObjectState.cs000644 001750 001750 00000004015 11520622640 027577 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs { /// The state of the entity in a provider. /// The state of the entity in a provider. /// Albert Kwan /// Klaus Wuestefeld /// 1.2 /// dRS 1.2 public interface IObjectState { /// The entity. /// The entity. /// null if the object has been deleted or if it was not replicated in previous replications. /// object GetObject(); /// Is the object newly created since last replication? /// true when the object is newly created since last replication bool IsNew(); /// Was the object modified since last replication? /// true when the object was modified since last replication bool WasModified(); /// The time when the object is modified in a provider. /// The time when the object is modified in a provider. /// time when the object is modified in a provider. long ModificationDate(); /// whether or not the object is known to the ReplicationProvider. /// whether or not the object is known to the ReplicationProvider. bool IsKnown(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/IReplicationEventListener.cs000644 001750 001750 00000002653 11520622640 032357 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs; namespace Db4objects.Drs { /// Defines the contract for handling of replication events generated from a replication session. /// /// /// Defines the contract for handling of replication events generated from a replication session. /// Users can implement this interface to resolve replication conflicts according to their own business rules. /// /// 1.2 /// dRS 1.2 public interface IReplicationEventListener { /// invoked when a replication of an object occurs. /// invoked when a replication of an object occurs. /// the event void OnReplicate(IReplicationEvent e); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/000755 001750 001750 00000000000 11520622066 025522 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/ReplicationRecord.cs000644 001750 001750 00000007606 11520622640 031470 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Query; namespace Db4objects.Drs.Db4o { /// /// tracks the version of the last replication between /// two Objectcontainers. /// /// /// tracks the version of the last replication between /// two Objectcontainers. /// /// /// public class ReplicationRecord : IInternal4 { public Db4oDatabase _youngerPeer; public Db4oDatabase _olderPeer; public long _version; public ReplicationRecord() { } public ReplicationRecord(Db4oDatabase younger, Db4oDatabase older) { _youngerPeer = younger; _olderPeer = older; } public virtual void SetVersion(long version) { _version = version; } public virtual void Store(ObjectContainerBase container) { container.ShowInternalClasses(true); try { Transaction trans = container.CheckTransaction(); container.StoreAfterReplication(trans, this, container.UpdateDepthProvider().ForDepth (1), false); container.Commit(trans); } finally { container.ShowInternalClasses(false); } } public static Db4objects.Drs.Db4o.ReplicationRecord BeginReplication(Transaction transA, Transaction transB) { ObjectContainerBase peerA = transA.Container(); ObjectContainerBase peerB = transB.Container(); Db4oDatabase dbA = ((IInternalObjectContainer)peerA).Identity(); Db4oDatabase dbB = ((IInternalObjectContainer)peerB).Identity(); dbB.Bind(transA); dbA.Bind(transB); Db4oDatabase younger = null; Db4oDatabase older = null; if (dbA.IsOlderThan(dbB)) { younger = dbB; older = dbA; } else { younger = dbA; older = dbB; } Db4objects.Drs.Db4o.ReplicationRecord rrA = QueryForReplicationRecord(peerA, transA , younger, older); Db4objects.Drs.Db4o.ReplicationRecord rrB = QueryForReplicationRecord(peerB, transB , younger, older); if (rrA == null) { if (rrB == null) { return new Db4objects.Drs.Db4o.ReplicationRecord(younger, older); } rrB.Store(peerA); return rrB; } if (rrB == null) { rrA.Store(peerB); return rrA; } if (rrA != rrB) { peerB.ShowInternalClasses(true); try { int id = peerB.GetID(transB, rrB); peerB.Bind(transB, rrA, id); } finally { peerB.ShowInternalClasses(false); } } return rrA; } public static Db4objects.Drs.Db4o.ReplicationRecord QueryForReplicationRecord(ObjectContainerBase container, Transaction trans, Db4oDatabase younger, Db4oDatabase older) { container.ShowInternalClasses(true); try { IQuery q = container.Query(trans); q.Constrain(typeof(Db4objects.Drs.Db4o.ReplicationRecord)); q.Descend("_youngerPeer").Constrain(younger).Identity(); q.Descend("_olderPeer").Constrain(older).Identity(); IObjectSet objectSet = q.Execute(); return objectSet.HasNext() ? (Db4objects.Drs.Db4o.ReplicationRecord)objectSet.Next () : null; } finally { container.ShowInternalClasses(false); } } } } src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/Db4oReplicationProviderSignature.cs000644 001750 001750 00000002402 11520622640 034345 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Ext; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Db4o { /// public class Db4oReplicationProviderSignature : IReadonlyReplicationProviderSignature { private readonly Db4oDatabase _delegate; public Db4oReplicationProviderSignature(Db4oDatabase delegate_) { _delegate = delegate_; } public virtual long GetId() { return 0; } public virtual byte[] GetSignature() { return _delegate.GetSignature(); } public virtual long GetCreated() { return _delegate.GetCreationTime(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/Db4oProviderFactory.cs000644 001750 001750 00000002556 11520622640 031712 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; using Db4objects.Db4o.Internal; using Db4objects.Drs.Db4o; namespace Db4objects.Drs.Db4o { /// public class Db4oProviderFactory { public static IDb4oReplicationProvider NewInstance(IObjectContainer oc, string name ) { if (IsClient(oc)) { return new Db4oClientServerReplicationProvider(oc, name); } else { return new Db4oEmbeddedReplicationProvider(oc, name); } } public static IDb4oReplicationProvider NewInstance(IObjectContainer oc) { return NewInstance(oc, null); } private static bool IsClient(IObjectContainer oc) { return ((IInternalObjectContainer)oc).IsClient; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/Db4oSignatureMap.cs000644 001750 001750 00000003154 11520622640 031162 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; namespace Db4objects.Drs.Db4o { internal class Db4oSignatureMap { private readonly IInternalObjectContainer _stream; private readonly Hashtable4 _identities; internal Db4oSignatureMap(IInternalObjectContainer stream) { _stream = stream; _identities = new Hashtable4(); } internal virtual Db4oDatabase Produce(byte[] signature, long creationTime) { Db4oDatabase db = (Db4oDatabase)_identities.Get(signature); if (db != null) { return db; } db = new Db4oDatabase(signature, creationTime); db.Bind(_stream.Transaction); _identities.Put(signature, db); return db; } public virtual void Put(Db4oDatabase db) { Db4oDatabase existing = (Db4oDatabase)_identities.Get(db.GetSignature()); if (existing == null) { _identities.Put(db.GetSignature(), db); } } } } src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/Db4oEmbeddedReplicationProvider.cs000644 001750 001750 00000031753 11520622640 034110 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o; using Db4objects.Db4o.Activation; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Replication; using Db4objects.Db4o.Query; using Db4objects.Db4o.Reflect; using Db4objects.Db4o.TA; using Db4objects.Drs.Db4o; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Db4o { public class Db4oEmbeddedReplicationProvider : IDb4oReplicationProvider { private IReadonlyReplicationProviderSignature _mySignature; protected readonly ExternalObjectContainer _container; private readonly IReflector _reflector; private ReplicationRecord _replicationRecord; internal Db4oReplicationReferenceImpl _referencesByObject; private Db4oSignatureMap _signatureMap; private readonly string _name; private readonly IProcedure4 _activationStrategy; private long _commitTimestamp; public Db4oEmbeddedReplicationProvider(IObjectContainer objectContainer, string name ) { // TODO: Add additional query methods (whereModified ) IConfiguration cfg = objectContainer.Ext().Configure(); cfg.Callbacks(false); _name = name; _container = (ExternalObjectContainer)objectContainer; _reflector = _container.Reflector(); _signatureMap = new Db4oSignatureMap(_container); _activationStrategy = CreateActivationStrategy(); } public Db4oEmbeddedReplicationProvider(IObjectContainer objectContainer) : this(objectContainer , objectContainer.ToString()) { } private IProcedure4 CreateActivationStrategy() { if (IsTransparentActivationEnabled()) { return new _IProcedure4_86(this); } return new _IProcedure4_94(this); } private sealed class _IProcedure4_86 : IProcedure4 { public _IProcedure4_86(Db4oEmbeddedReplicationProvider _enclosing) { this._enclosing = _enclosing; } public void Apply(object obj) { IObjectInfo objectInfo = this._enclosing._container.GetObjectInfo(obj); ((IActivator)objectInfo).Activate(ActivationPurpose.Read); } private readonly Db4oEmbeddedReplicationProvider _enclosing; } private sealed class _IProcedure4_94 : IProcedure4 { public _IProcedure4_94(Db4oEmbeddedReplicationProvider _enclosing) { this._enclosing = _enclosing; } public void Apply(object obj) { if (obj == null) { return; } IReflectClass claxx = this._enclosing._reflector.ForObject(obj); int level = claxx.IsCollection() ? 3 : 1; this._enclosing._container.Activate(obj, level); } private readonly Db4oEmbeddedReplicationProvider _enclosing; } private bool IsTransparentActivationEnabled() { return TransparentActivationSupport.IsTransparentActivationEnabledOn(_container); } public virtual IReadonlyReplicationProviderSignature GetSignature() { if (_mySignature == null) { _mySignature = new Db4oReplicationProviderSignature(_container.Identity()); } return _mySignature; } private object Lock() { return _container.Lock(); } public virtual void StartReplicationTransaction(IReadonlyReplicationProviderSignature peerSignature) { ClearAllReferences(); lock (Lock()) { Transaction trans = _container.Transaction; Db4oDatabase myIdentity = _container.Identity(); _signatureMap.Put(myIdentity); Db4oDatabase otherIdentity = _signatureMap.Produce(peerSignature.GetSignature(), peerSignature.GetCreated()); Db4oDatabase younger = null; Db4oDatabase older = null; if (myIdentity.IsOlderThan(otherIdentity)) { younger = otherIdentity; older = myIdentity; } else { younger = myIdentity; older = otherIdentity; } _replicationRecord = ReplicationRecord.QueryForReplicationRecord(_container, trans , younger, older); if (_replicationRecord == null) { _replicationRecord = new ReplicationRecord(younger, older); _replicationRecord.Store(_container); } else { _container.RaiseCommitTimestamp(_replicationRecord._version + 1); } _commitTimestamp = _container.GenerateTransactionTimestamp(0); } } public virtual void CommitReplicationTransaction() { StoreReplicationRecord(); _container.Commit(); _container.UseDefaultTransactionTimestamp(); } private void StoreReplicationRecord() { _replicationRecord._version = _commitTimestamp; _replicationRecord.Store(_container); } public virtual void RollbackReplication() { _container.Rollback(); _referencesByObject = null; } public virtual long GetLastReplicationVersion() { return _replicationRecord._version; } public virtual void StoreReplica(object obj) { Logger4Support.LogIdentity(obj, GetName()); lock (Lock()) { _container.StoreByNewReplication(this, obj); } } public virtual void Activate(object obj) { _activationStrategy.Apply(obj); } public virtual IDb4oReplicationReference ReferenceFor(object obj) { if (_referencesByObject == null) { return null; } return _referencesByObject.Find(obj); } public virtual IReplicationReference ProduceReference(object obj, object unused, string unused2) { if (obj == null) { return null; } if (_referencesByObject != null) { Db4oReplicationReferenceImpl existingNode = _referencesByObject.Find(obj); if (existingNode != null) { return existingNode; } } // TODO: Why refresh here? Try without and run all tests! Refresh(obj); IObjectInfo objectInfo = _container.GetObjectInfo(obj); if (objectInfo == null) { return null; } Db4oUUID uuid = objectInfo.GetUUID(); if (uuid == null) { throw new ArgumentNullException(); } Db4oReplicationReferenceImpl newNode = new Db4oReplicationReferenceImpl(objectInfo , obj); AddReference(newNode); return newNode; } protected virtual void Refresh(object obj) { } //empty in File Provider private void AddReference(Db4oReplicationReferenceImpl newNode) { if (_referencesByObject == null) { _referencesByObject = newNode; } else { _referencesByObject = _referencesByObject.Add(newNode); } } public virtual IReplicationReference ReferenceNewObject(object obj, IReplicationReference counterpartReference, IReplicationReference referencingObjCounterPartRef, string fieldName) { IDrsUUID uuid = counterpartReference.Uuid(); if (uuid == null) { return null; } byte[] signature = uuid.GetSignaturePart(); long longPart = uuid.GetLongPart(); long version = counterpartReference.Version(); Db4oDatabase db = _signatureMap.Produce(signature, 0); Db4oReplicationReferenceImpl @ref = new Db4oReplicationReferenceImpl(obj, db, longPart , version); AddReference(@ref); return @ref; } public virtual IReplicationReference ProduceReferenceByUUID(IDrsUUID uuid, Type hint ) { if (uuid == null) { return null; } object obj = _container.GetByUUID(new Db4oUUID(uuid.GetLongPart(), uuid.GetSignaturePart ())); if (obj == null) { return null; } if (!_container.IsActive(obj)) { _container.Activate(obj, 1); } return ProduceReference(obj); } public virtual void VisitCachedReferences(IVisitor4 visitor) { if (_referencesByObject != null) { _referencesByObject.Traverse(new _IVisitor4_284(visitor)); } } private sealed class _IVisitor4_284 : IVisitor4 { public _IVisitor4_284(IVisitor4 visitor) { this.visitor = visitor; } public void Visit(object obj) { Db4oReplicationReferenceImpl node = (Db4oReplicationReferenceImpl)obj; visitor.Visit(node); } private readonly IVisitor4 visitor; } public virtual void ClearAllReferences() { _referencesByObject = null; } public virtual IObjectSet ObjectsChangedSinceLastReplication() { IQuery q = _container.Query(); WhereModified(q); return q.Execute(); } public virtual IObjectSet ObjectsChangedSinceLastReplication(Type clazz) { IQuery q = _container.Query(); q.Constrain(clazz); WhereModified(q); return q.Execute(); } /// /// adds a constraint to the passed Query to query only for objects that were /// modified since the last replication process between this and the other /// ObjectContainer involved in the current replication process. /// /// /// adds a constraint to the passed Query to query only for objects that were /// modified since the last replication process between this and the other /// ObjectContainer involved in the current replication process. /// /// the Query to be constrained public virtual void WhereModified(IQuery query) { query.Descend(VirtualField.CommitTimestamp).Constrain(GetLastReplicationVersion() ).Greater(); } public virtual IObjectSet GetStoredObjects(Type type) { IQuery query = _container.Query(); query.Constrain(type); return query.Execute(); } public virtual void StoreNew(object o) { Logger4Support.LogIdentity(o, GetName()); _container.Store(o); } public virtual void Update(object o) { _container.Store(o); } public virtual string GetName() { return _name; } public virtual void Destroy() { } // do nothing public virtual void Commit() { _container.Commit(); } public virtual void DeleteAllInstances(Type clazz) { IQuery q = _container.Query(); q.Constrain(clazz); IEnumerator objectSet = q.Execute().GetEnumerator(); while (objectSet.MoveNext()) { Delete(objectSet.Current); } } public virtual void Delete(object obj) { _container.Delete(obj); } public virtual bool WasModifiedSinceLastReplication(IReplicationReference reference ) { return reference.Version() > GetLastReplicationVersion(); } public virtual bool SupportsMultiDimensionalArrays() { return true; } public virtual bool SupportsHybridCollection() { return true; } public virtual bool SupportsRollback() { return false; } public override string ToString() { return GetName(); } public virtual void ReplicateDeletion(IDrsUUID uuid) { object obj = _container.GetByUUID(new Db4oUUID(uuid.GetLongPart(), uuid.GetSignaturePart ())); if (obj == null) { return; } _container.Delete(obj); } public virtual IExtObjectContainer GetObjectContainer() { return _container; } public virtual bool IsProviderSpecific(object original) { return false; } public virtual void ReplicationReflector(Db4objects.Drs.Inside.ReplicationReflector replicationReflector) { } public virtual IObjectSet GetStoredObjects() { return _container.Query().Execute(); } public virtual IReplicationReference ProduceReference(object obj) { return ProduceReference(obj, null, null); } public virtual object ReplaceIfSpecific(object value) { return value; } public virtual bool IsSecondClassObject(object obj) { return false; } public virtual long ObjectVersion(object @object) { return _container.GetObjectInfo(@object).GetCommitTimestamp(); } public virtual long CreationTime(object @object) { return _container.GetObjectInfo(@object).GetUUID().GetLongPart(); } public virtual void EnsureVersionsAreGenerated() { Commit(); } public virtual Db4objects.Drs.Foundation.TimeStamps TimeStamps() { return new Db4objects.Drs.Foundation.TimeStamps(_replicationRecord._version, _commitTimestamp ); } public virtual void WaitForPreviousCommits() { } // do nothing public virtual void SyncCommitTimestamp(long syncedTimeStamp) { if (syncedTimeStamp <= _commitTimestamp) { return; } _commitTimestamp = syncedTimeStamp; _container.RaiseCommitTimestamp(syncedTimeStamp + 1); _container.GenerateTransactionTimestamp(syncedTimeStamp); } } } src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/Db4oClientServerReplicationProvider.cs000644 001750 001750 00000002305 11520622640 035013 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; using Db4objects.Drs.Db4o; namespace Db4objects.Drs.Db4o { public class Db4oClientServerReplicationProvider : Db4oEmbeddedReplicationProvider { public Db4oClientServerReplicationProvider(IObjectContainer objectContainer) : base (objectContainer, "null") { } public Db4oClientServerReplicationProvider(IObjectContainer objectContainer, string name) : base(objectContainer, name) { } protected override void Refresh(object obj) { _container.Refresh(obj, 1); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/IDb4oReplicationProvider.cs000644 001750 001750 00000002000 11520622640 032645 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal.Replication; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Db4o { public interface IDb4oReplicationProvider : ITestableReplicationProvider, IDb4oReplicationReferenceProvider , ITestableReplicationProviderInside { IExtObjectContainer GetObjectContainer(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Db4o/Db4oReplicationReferenceImpl.cs000644 001750 001750 00000011310 11520622640 033466 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Replication; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Db4o { /// public class Db4oReplicationReferenceImpl : ObjectReference, IReplicationReference , IDb4oReplicationReference { private object _counterPart; private bool _markedForReplicating; private bool _markedForDeleting; private readonly long _version; internal Db4oReplicationReferenceImpl(IObjectInfo objectInfo, object obj) { if (obj == null) { throw new InvalidOperationException("obj may not be null"); } _version = objectInfo.GetCommitTimestamp(); ObjectReference @ref = (ObjectReference)objectInfo; Transaction trans = @ref.Transaction(); Db4objects.Db4o.Internal.VirtualAttributes va = @ref.VirtualAttributes(trans); if (va != null) { SetVirtualAttributes((Db4objects.Db4o.Internal.VirtualAttributes)va.ShallowClone( )); } else { SetVirtualAttributes(new Db4objects.Db4o.Internal.VirtualAttributes()); } SetObject(obj); Ref_init(); } public Db4oReplicationReferenceImpl(object obj, Db4oDatabase db, long longPart, long version) { if (obj == null) { throw new InvalidOperationException("obj may not be null"); } SetObject(obj); Ref_init(); Db4objects.Db4o.Internal.VirtualAttributes va = new Db4objects.Db4o.Internal.VirtualAttributes (); va.i_database = db; va.i_uuid = longPart; va.i_version = version; _version = version; SetVirtualAttributes(va); } public virtual Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl Add(Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl newNode) { return (Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl)Hc_add(newNode); } public virtual Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl Find(object obj) { return (Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl)Hc_find(obj); } public virtual void Traverse(IVisitor4 visitor) { Hc_traverse(visitor); } public virtual IDrsUUID Uuid() { Db4oDatabase db = SignaturePart(); if (db == null) { return null; } return new DrsUUIDImpl(new Db4oUUID(LongPart(), db.GetSignature())); } public virtual long Version() { return _version; } public virtual object Object() { return GetObject(); } public virtual object Counterpart() { return _counterPart; } public virtual void SetCounterpart(object obj) { _counterPart = obj; } public virtual void MarkForReplicating(bool flag) { _markedForReplicating = flag; } public virtual bool IsMarkedForReplicating() { return _markedForReplicating; } public virtual void MarkForDeleting() { _markedForDeleting = true; } public virtual bool IsMarkedForDeleting() { return _markedForDeleting; } public virtual void MarkCounterpartAsNew() { throw new NotSupportedException("TODO"); } public virtual bool IsCounterpartNew() { throw new NotSupportedException("TODO"); } public virtual Db4oDatabase SignaturePart() { return VirtualAttributes().i_database; } public virtual long LongPart() { return VirtualAttributes().i_uuid; } public override Db4objects.Db4o.Internal.VirtualAttributes VirtualAttributes() { return VirtualAttributes(null); } public sealed override bool Equals(object o) { if (this == o) { return true; } if (o == null || o.GetType() != GetType()) { return false; } Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl other = (Db4objects.Drs.Db4o.Db4oReplicationReferenceImpl )o; return Version() == other.Version() && Uuid().Equals(other.Uuid()); } public sealed override int GetHashCode() { return 29 * Uuid().GetHashCode() + (int)(Version() ^ ((Version()) >> (32 & 0x1f)) ); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/000755 001750 001750 00000000000 11520622070 026140 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ICollectionSource.cs000644 001750 001750 00000001450 11520622640 032057 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Inside { public interface ICollectionSource { bool IsProviderSpecific(object original); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/GenericReplicationSession.cs000644 001750 001750 00000033126 11520622640 033611 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Reflect; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Inside.Traversal; namespace Db4objects.Drs.Inside { public sealed class GenericReplicationSession : IReplicationSession { private const int Size = 10000; private readonly ReplicationReflector _reflector; private readonly Db4objects.Drs.Inside.ICollectionHandler _collectionHandler; private IReplicationProviderInside _providerA; private IReplicationProviderInside _providerB; private IReplicationProvider _directionTo; private readonly IReplicationEventListener _listener; private readonly ITraverser _traverser; private HashSet4 _processedUuids = new HashSet4(Size); private bool _isReplicatingOnlyDeletions; public GenericReplicationSession(IReplicationProviderInside _peerA, IReplicationProviderInside _peerB) : this(_peerA, _peerB, new DefaultReplicationEventListener()) { } public GenericReplicationSession(IReplicationProvider providerA, IReplicationProvider providerB, IReplicationEventListener listener) : this(providerA, providerB, listener , null) { } public GenericReplicationSession(IReplicationProvider providerA, IReplicationProvider providerB, IReplicationEventListener listener, IReflector reflector) { //null means bidirectional replication. _reflector = new ReplicationReflector(providerA, providerB, reflector); _collectionHandler = new CollectionHandlerImpl(_reflector); _traverser = new GenericTraverser(_reflector, _collectionHandler); _providerA = (IReplicationProviderInside)providerA; _providerB = (IReplicationProviderInside)providerB; _listener = listener; _providerA.StartReplicationTransaction(_providerB.GetSignature()); _providerB.StartReplicationTransaction(_providerA.GetSignature()); long syncedTimeStamp = Math.Max(_providerA.TimeStamps().Commit(), _providerB.TimeStamps ().Commit()); _providerA.SyncCommitTimestamp(syncedTimeStamp); _providerB.SyncCommitTimestamp(syncedTimeStamp); } public void Close() { _providerA.Destroy(); _providerB.Destroy(); _providerA = null; _providerB = null; _processedUuids = null; } public void Commit() { _providerA.CommitReplicationTransaction(); _providerB.CommitReplicationTransaction(); } public IReplicationProvider ProviderA() { return _providerA; } public IReplicationProvider ProviderB() { return _providerB; } public void Replicate(object root) { try { PrepareGraphToBeReplicated(root); CopyStateAcross(_providerA, _providerB); CopyStateAcross(_providerB, _providerA); StoreChangedObjectsIn(_providerA); StoreChangedObjectsIn(_providerB); } finally { _providerA.ClearAllReferences(); _providerB.ClearAllReferences(); } } public void ReplicateDeletions(Type extent) { ReplicateDeletions(extent, _providerA); ReplicateDeletions(extent, _providerB); } private void ReplicateDeletions(Type extent, IReplicationProviderInside provider) { _isReplicatingOnlyDeletions = true; try { IEnumerator instances = provider.GetStoredObjects(extent).GetEnumerator(); while (instances.MoveNext()) { Replicate(instances.Current); } } finally { _isReplicatingOnlyDeletions = false; } } public void Rollback() { // TODO: Write tests for rollback. _providerA.RollbackReplication(); _providerB.RollbackReplication(); } public void SetDirection(IReplicationProvider replicateFrom, IReplicationProvider replicateTo) { if (replicateFrom == _providerA && replicateTo == _providerB) { _directionTo = _providerB; } if (replicateFrom == _providerB && replicateTo == _providerA) { _directionTo = _providerA; } } private void PrepareGraphToBeReplicated(object root) { _traverser.TraverseGraph(root, new InstanceReplicationPreparer(_providerA, _providerB , _directionTo, _listener, _isReplicatingOnlyDeletions, _processedUuids, _traverser , _reflector, _collectionHandler)); } private object ArrayClone(object original, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { IReflectClass componentType = _reflector.GetComponentType(claxx); int[] dimensions = _reflector.ArrayDimensions(original); object result = _reflector.NewArrayInstance(componentType, dimensions); object[] flatContents = _reflector.ArrayContents(original); //TODO Optimize: Copy the structure without flattening. Do this in ReflectArray. if (!(_reflector.IsValueType(claxx) || _reflector.IsValueType(componentType))) { ReplaceWithCounterparts(flatContents, sourceProvider, targetProvider); } _reflector.ArrayShape(flatContents, 0, result, dimensions, 0); return result; } private void CopyFieldValuesAcross(object src, object dest, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider ) { if (dest == null) { throw new InvalidOperationException("Dest cannot be null: src=" + src + ", class=" + claxx + ", source=" + sourceProvider.GetName() + ", target=" + targetProvider .GetName()); } IEnumerator fields = FieldIterators.PersistentFields(claxx); while (fields.MoveNext()) { IReflectField field = (IReflectField)fields.Current; object value = field.Get(src); field.Set(dest, FindCounterpart(value, sourceProvider, targetProvider)); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } CopyFieldValuesAcross(src, dest, superclass, sourceProvider, targetProvider); } private void CopyStateAcross(IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { if (_directionTo == sourceProvider) { return; } sourceProvider.VisitCachedReferences(new _IVisitor4_182(this, sourceProvider, targetProvider )); } private sealed class _IVisitor4_182 : IVisitor4 { public _IVisitor4_182(GenericReplicationSession _enclosing, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { this._enclosing = _enclosing; this.sourceProvider = sourceProvider; this.targetProvider = targetProvider; } public void Visit(object obj) { this._enclosing.CopyStateAcross((IReplicationReference)obj, sourceProvider, targetProvider ); } private readonly GenericReplicationSession _enclosing; private readonly IReplicationProviderInside sourceProvider; private readonly IReplicationProviderInside targetProvider; } private void CopyStateAcross(IReplicationReference sourceRef, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { if (!sourceRef.IsMarkedForReplicating()) { return; } object source = sourceRef.Object(); object target = sourceRef.Counterpart(); if (source == null) { throw new InvalidOperationException("source may not be null"); } if (target == null) { throw new InvalidOperationException("target may not be null"); } CopyStateAcross(source, target, sourceProvider, targetProvider); } private void CopyStateAcross(object source, object dest, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { IReflectClass claxx = _reflector.ForObject(source); CopyFieldValuesAcross(source, dest, claxx, sourceProvider, targetProvider); } private void DeleteInDestination(IReplicationReference reference, IReplicationProviderInside destination) { if (!reference.IsMarkedForDeleting()) { return; } destination.ReplicateDeletion(reference.Uuid()); } private object FindCounterpart(object value, IReplicationProviderInside sourceProvider , IReplicationProviderInside targetProvider) { if (value == null) { return null; } value = sourceProvider.ReplaceIfSpecific(value); // TODO: need to clone and findCounterpart of each reference object in the // struct if (ReplicationPlatform.IsValueType(value)) { return value; } IReflectClass claxx = _reflector.ForObject(value); if (claxx.IsArray()) { return ArrayClone(value, claxx, sourceProvider, targetProvider); } if (Platform4.IsTransient(claxx)) { return null; } // TODO: make it a warning if (_reflector.IsValueType(claxx)) { return value; } if (_collectionHandler.CanHandle(value)) { return CollectionClone(value, claxx, sourceProvider, targetProvider); } //if value is a Collection, result should be found by passing in just the value IReplicationReference @ref = sourceProvider.ProduceReference(value, null, null); if (@ref == null) { throw new InvalidOperationException("unable to find the ref of " + value + " of class " + value.GetType()); } object result = @ref.Counterpart(); if (result != null) { return result; } IReplicationReference targetRef = targetProvider.ProduceReferenceByUUID(@ref.Uuid (), value.GetType()); if (targetRef == null) { throw new InvalidOperationException("unable to find the counterpart of " + value + " of class " + value.GetType()); } return targetRef.Object(); } private object CollectionClone(object original, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { return _collectionHandler.CloneWithCounterparts(sourceProvider, original, claxx, new _ICounterpartFinder_248(this, sourceProvider, targetProvider)); } private sealed class _ICounterpartFinder_248 : ICounterpartFinder { public _ICounterpartFinder_248(GenericReplicationSession _enclosing, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { this._enclosing = _enclosing; this.sourceProvider = sourceProvider; this.targetProvider = targetProvider; } public object FindCounterpart(object original) { return this._enclosing.FindCounterpart(original, sourceProvider, targetProvider); } private readonly GenericReplicationSession _enclosing; private readonly IReplicationProviderInside sourceProvider; private readonly IReplicationProviderInside targetProvider; } private IReplicationProviderInside Other(IReplicationProviderInside peer) { return peer == _providerA ? _providerB : _providerA; } private void ReplaceWithCounterparts(object[] objects, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider) { for (int i = 0; i < objects.Length; i++) { object @object = objects[i]; if (@object == null) { continue; } objects[i] = FindCounterpart(@object, sourceProvider, targetProvider); } } private void StoreChangedCounterpartInDestination(IReplicationReference reference , IReplicationProviderInside destination) { //System.out.println("reference = " + reference); bool markedForReplicating = reference.IsMarkedForReplicating(); //System.out.println("markedForReplicating = " + markedForReplicating); if (!markedForReplicating) { return; } destination.StoreReplica(reference.Counterpart()); } private void StoreChangedObjectsIn(IReplicationProviderInside destination) { IReplicationProviderInside source = Other(destination); if (_directionTo == source) { return; } destination.VisitCachedReferences(new _IVisitor4_280(this, destination)); source.VisitCachedReferences(new _IVisitor4_286(this, destination)); } private sealed class _IVisitor4_280 : IVisitor4 { public _IVisitor4_280(GenericReplicationSession _enclosing, IReplicationProviderInside destination) { this._enclosing = _enclosing; this.destination = destination; } public void Visit(object obj) { this._enclosing.DeleteInDestination((IReplicationReference)obj, destination); } private readonly GenericReplicationSession _enclosing; private readonly IReplicationProviderInside destination; } private sealed class _IVisitor4_286 : IVisitor4 { public _IVisitor4_286(GenericReplicationSession _enclosing, IReplicationProviderInside destination) { this._enclosing = _enclosing; this.destination = destination; } public void Visit(object obj) { this._enclosing.StoreChangedCounterpartInDestination((IReplicationReference)obj, destination); } private readonly GenericReplicationSession _enclosing; private readonly IReplicationProviderInside destination; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ICounterpartFinder.cs000644 001750 001750 00000001450 11520622640 032241 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Inside { public interface ICounterpartFinder { object FindCounterpart(object original); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ISimpleObjectContainer.cs000644 001750 001750 00000002274 11520622640 033033 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o; namespace Db4objects.Drs.Inside { public interface ISimpleObjectContainer { void Activate(object @object); void Commit(); void Delete(object obj); void DeleteAllInstances(Type clazz); IObjectSet GetStoredObjects(Type type); /// Will cascade to save the whole graph of objects void StoreNew(object o); /// Updating won't cascade. /// Updating won't cascade. void Update(object o); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ReplicationReferenceImpl.cs000644 001750 001750 00000005574 11520622640 033417 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { public class ReplicationReferenceImpl : IReplicationReference { private bool _objectIsNew; private readonly object _obj; private readonly IDrsUUID _uuid; private readonly long _version; private object _counterPart; private bool _markedForReplicating; private bool _markedForDeleting; public ReplicationReferenceImpl(object obj, IDrsUUID uuid, long version) { this._obj = obj; this._uuid = uuid; this._version = version; } public object Counterpart() { return _counterPart; } public sealed override bool Equals(object o) { if (this == o) { return true; } if (o == null || o.GetType() != GetType()) { return false; } Db4objects.Drs.Inside.ReplicationReferenceImpl other = (Db4objects.Drs.Inside.ReplicationReferenceImpl )o; return _version == other._version && _uuid.Equals(other._uuid); } public sealed override int GetHashCode() { return 29 * _uuid.GetHashCode() + (int)(_version ^ ((_version) >> (32 & 0x1f))); } public virtual bool IsCounterpartNew() { return _objectIsNew; } public bool IsMarkedForDeleting() { return _markedForDeleting; } public bool IsMarkedForReplicating() { return _markedForReplicating; } public virtual void MarkCounterpartAsNew() { _objectIsNew = true; } public void MarkForDeleting() { _markedForDeleting = true; } public void MarkForReplicating(bool flag) { _markedForReplicating = flag; } public object Object() { return _obj; } public void SetCounterpart(object obj) { _counterPart = obj; } public override string ToString() { return "ReplicationReferenceImpl{" + "_objectIsNew=" + _objectIsNew + ", _obj=" + _obj + ", _uuid=" + _uuid + ", _version=" + _version + ", _counterPart=" + _counterPart + ", _markedForReplicating=" + _markedForReplicating + ", _markedForDeleting=" + _markedForDeleting + '}'; } public IDrsUUID Uuid() { return _uuid; } public long Version() { return _version; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ICollectionHandler.cs000644 001750 001750 00000002332 11520622640 032174 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Reflect; using Db4objects.Drs.Inside; using Db4objects.Drs.Inside.Traversal; namespace Db4objects.Drs.Inside { public interface ICollectionHandler : ICollectionFlattener { object EmptyClone(ICollectionSource sourceProvider, object originalCollection, IReflectClass originalCollectionClass); void CopyState(object original, object dest, ICounterpartFinder finder); object CloneWithCounterparts(ICollectionSource sourceProvider, object original, IReflectClass claxx, ICounterpartFinder elementCloner); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ReplicationEventImpl.cs000644 001750 001750 00000004065 11520622640 032574 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Drs; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { internal sealed class ReplicationEventImpl : IReplicationEvent { internal readonly ObjectStateImpl _stateInProviderA = new ObjectStateImpl(); internal readonly ObjectStateImpl _stateInProviderB = new ObjectStateImpl(); private bool _isConflict; internal IObjectState _actionChosenState; internal bool _actionWasChosen; internal bool _actionShouldStopTraversal; internal long _creationDate; public IObjectState StateInProviderA() { return _stateInProviderA; } public IObjectState StateInProviderB() { return _stateInProviderB; } public long ObjectCreationDate() { return _creationDate; } public bool IsConflict() { return _isConflict; } public void OverrideWith(IObjectState chosen) { if (_actionWasChosen) { throw new Exception(); } //FIXME Use Db4o's standard exception throwing. _actionWasChosen = true; _actionChosenState = chosen; } public void StopTraversal() { _actionShouldStopTraversal = true; } internal void ResetAction() { _actionChosenState = null; _actionWasChosen = false; _actionShouldStopTraversal = false; _creationDate = -1; } internal void Conflict(bool isConflict) { _isConflict = isConflict; } } } src/drs/Db4objects.Drs/Db4objects.Drs/Inside/DefaultReplicationEventListener.cs000644 001750 001750 00000003217 11520622640 034704 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs; namespace Db4objects.Drs.Inside { /// A default implementation of ConflictResolver. /// /// A default implementation of ConflictResolver. In case of a conflict, /// if the object is known to only one database the object is copied /// to the other database. If the object is known in both databases /// a /// Db4objects.Drs.ReplicationConflictException /// /// is thrown. /// /// 1.1 /// dRS 1.0 public class DefaultReplicationEventListener : IReplicationEventListener { public virtual void OnReplicate(IReplicationEvent e) { if (e.IsConflict()) { if (!e.StateInProviderA().IsKnown()) { e.OverrideWith(e.StateInProviderB()); } else { if (!e.StateInProviderB().IsKnown()) { e.OverrideWith(e.StateInProviderA()); } } } } } } src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ITestableReplicationProviderInside.cs000644 001750 001750 00000002135 11520622640 035331 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { public interface ITestableReplicationProviderInside : IReplicationProviderInside, ISimpleObjectContainer { bool SupportsMultiDimensionalArrays(); bool SupportsHybridCollection(); bool SupportsRollback(); void Commit(); long ObjectVersion(object storedObject); void WaitForPreviousCommits(); long CreationTime(object obj); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/MapHandler.cs000644 001750 001750 00000006274 11520622640 030516 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { public class MapHandler : Db4objects.Drs.Inside.ICollectionHandler { private readonly IReflectClass _reflectMapClass; private readonly ReplicationReflector _reflector; public MapHandler(ReplicationReflector reflector) { _reflector = reflector; _reflectMapClass = reflector.ForClass(typeof(IDictionary)); } public virtual bool CanHandleClass(IReflectClass claxx) { return _reflectMapClass.IsAssignableFrom(claxx); } public virtual bool CanHandle(object obj) { return CanHandleClass(_reflector.ForObject(obj)); } public virtual bool CanHandleClass(Type c) { return CanHandleClass(_reflector.ForClass(c)); } public virtual IEnumerator IteratorFor(object collection) { IDictionary map = (IDictionary)collection; Collection4 result = new Collection4(); IEnumerator it = map.GetEnumerator(); while (it.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)it.Current; result.Add(entry.Key); result.Add(entry.Value); } return result.GetEnumerator(); } public virtual object EmptyClone(ICollectionSource sourceProvider, object original , IReflectClass originalCollectionClass) { if (sourceProvider.IsProviderSpecific(original) || original is Hashtable) { return new Hashtable(((IDictionary)original).Count); } return _reflector.ForObject(original).NewInstance(); } public virtual void CopyState(object original, object destination, ICounterpartFinder counterpartFinder) { IDictionary originalMap = (IDictionary)original; IDictionary destinationMap = (IDictionary)destination; destinationMap.Clear(); IEnumerator it = originalMap.GetEnumerator(); while (it.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)it.Current; object keyClone = counterpartFinder.FindCounterpart(entry.Key); object valueClone = counterpartFinder.FindCounterpart(entry.Value); destinationMap[keyClone] = valueClone; } } public virtual object CloneWithCounterparts(ICollectionSource sourceProvider, object originalMap, IReflectClass claxx, ICounterpartFinder elementCloner) { IDictionary original = (IDictionary)originalMap; IDictionary result = (IDictionary)EmptyClone(sourceProvider, original, claxx); CopyState(original, result, elementCloner); return result; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/CollectionHandlerImpl.cs000644 001750 001750 00000007245 11520622640 032715 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { public class CollectionHandlerImpl : Db4objects.Drs.Inside.ICollectionHandler { private readonly Db4objects.Drs.Inside.ICollectionHandler _mapHandler; private readonly ReplicationReflector _reflector; public CollectionHandlerImpl(ReplicationReflector reflector) { _mapHandler = new MapHandler(reflector); _reflector = reflector; } public virtual bool CanHandleClass(IReflectClass claxx) { if (_mapHandler.CanHandleClass(claxx)) { return true; } return ReplicationPlatform.IsBuiltinCollectionClass(_reflector, claxx); } public virtual bool CanHandle(object obj) { return CanHandleClass(_reflector.ForObject(obj)); } public virtual bool CanHandleClass(Type c) { return CanHandleClass(_reflector.ForClass(c)); } public virtual object EmptyClone(ICollectionSource sourceProvider, object originalCollection , IReflectClass originalCollectionClass) { if (_mapHandler.CanHandleClass(originalCollectionClass)) { return _mapHandler.EmptyClone(sourceProvider, originalCollection, originalCollectionClass ); } ICollection original = (ICollection)originalCollection; ICollection clone = ReplicationPlatform.EmptyCollectionClone(sourceProvider, original ); if (null != clone) { return clone; } return _reflector.ForClass(original.GetType()).NewInstance(); } public virtual IEnumerator IteratorFor(object collection) { if (_mapHandler.CanHandleClass(_reflector.ForObject(collection))) { return _mapHandler.IteratorFor(collection); } IEnumerable subject = (IEnumerable)collection; return Copy(subject).GetEnumerator(); } private Collection4 Copy(IEnumerable subject) { Collection4 result = new Collection4(); IEnumerator it = subject.GetEnumerator(); while (it.MoveNext()) { result.Add(it.Current); } return result; } public virtual void CopyState(object original, object destination, ICounterpartFinder counterpartFinder) { if (_mapHandler.CanHandle(original)) { _mapHandler.CopyState(original, destination, counterpartFinder); } else { ReplicationPlatform.CopyCollectionState(original, destination, counterpartFinder); } } public virtual object CloneWithCounterparts(ICollectionSource sourceProvider, object originalCollection, IReflectClass claxx, ICounterpartFinder counterpartFinder) { if (_mapHandler.CanHandleClass(claxx)) { return _mapHandler.CloneWithCounterparts(sourceProvider, originalCollection, claxx , counterpartFinder); } ICollection original = (ICollection)originalCollection; ICollection result = (ICollection)EmptyClone(sourceProvider, originalCollection, claxx); CopyState(original, result, counterpartFinder); return result; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ObjectStateImpl.cs000644 001750 001750 00000003360 11520622640 031525 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs; namespace Db4objects.Drs.Inside { public class ObjectStateImpl : IObjectState { public const long Unknown = -1; private object _object; private bool _isNew; private bool _wasModified; private long _modificationDate; public virtual object GetObject() { return _object; } public virtual bool IsNew() { return _isNew; } public virtual bool WasModified() { return _wasModified; } public virtual long ModificationDate() { return _modificationDate; } internal virtual void SetAll(object obj, bool isNew, bool wasModified, long modificationDate ) { _object = obj; _isNew = isNew; _wasModified = wasModified; _modificationDate = modificationDate; } public override string ToString() { return "ObjectStateImpl{" + "_object=" + _object + ", _isNew=" + _isNew + ", _wasModified=" + _wasModified + ", _modificationDate=" + _modificationDate + '}'; } public virtual bool IsKnown() { return _modificationDate != Unknown; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ITestableReplicationProvider.cs000644 001750 001750 00000001554 11520622640 034260 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { public interface ITestableReplicationProvider : IReplicationProvider, ISimpleObjectContainer { } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/IReplicationProviderInside.cs000644 001750 001750 00000010460 11520622640 033724 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Foundation; using Db4objects.Drs; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; namespace Db4objects.Drs.Inside { public interface IReplicationProviderInside : IReplicationProvider, ICollectionSource , ISimpleObjectContainer { /// Clear the ReplicationReference cache void ClearAllReferences(); void CommitReplicationTransaction(); /// Destroys this provider and frees up resources. /// Destroys this provider and frees up resources. void Destroy(); long GetLastReplicationVersion(); string GetName(); IReadonlyReplicationProviderSignature GetSignature(); IReplicationReference ProduceReference(object obj); /// /// Collection version of getting a ReplicationReference: /// If the object is not a first class object, we need the /// parent object. /// /// /// Collection version of getting a ReplicationReference: /// If the object is not a first class object, we need the /// parent object. /// /// null, if there is no reference for this object. IReplicationReference ProduceReference(object obj, object parentObject, string fieldNameOnParent ); /// Returns the ReplicationReference of an object by specifying the uuid of the object. /// /// Returns the ReplicationReference of an object by specifying the uuid of the object. /// /// the uuid of the object /// the type of the object /// the ReplicationReference or null if the reference cannot be found IReplicationReference ProduceReferenceByUUID(IDrsUUID uuid, Type hint); IReplicationReference ReferenceNewObject(object obj, IReplicationReference counterpartReference , IReplicationReference referencingObjRef, string fieldName); /// Rollbacks all changes done during the replication session and terminates the Transaction. /// /// /// Rollbacks all changes done during the replication session and terminates the Transaction. /// Guarantees the changes will not be applied to the underlying databases. /// void RollbackReplication(); /// Start a Replication Transaction with another ReplicationProvider /// the signature of another ReplicationProvider. void StartReplicationTransaction(IReadonlyReplicationProviderSignature peerSignature ); /// Stores the new replicated state of obj. /// /// Stores the new replicated state of obj. It can also be a new object to this /// provider. /// /// Object with updated state or a clone of new object in the peer. /// void StoreReplica(object obj); /// Visits the object of each cached ReplicationReference. /// Visits the object of each cached ReplicationReference. /// implements the visit functions, including copying of object states, and storing of changed objects /// void VisitCachedReferences(IVisitor4 visitor); bool WasModifiedSinceLastReplication(IReplicationReference reference); void ReplicateDeletion(IDrsUUID uuid); object ReplaceIfSpecific(object value); bool IsSecondClassObject(object obj); void EnsureVersionsAreGenerated(); Db4objects.Drs.Foundation.TimeStamps TimeStamps(); void SyncCommitTimestamp(long syncedTimeStamp); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/DrsDebug.cs000644 001750 001750 00000002023 11520622640 030166 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Inside { public class DrsDebug { private static bool production = false; public static readonly bool runEventListenerEmbedded = !production; public const bool verbose = false; public const bool fastReplicationFeaturesMain = true; public static long Timeout(long designed) { return designed; } } } src/drs/Db4objects.Drs/Db4objects.Drs/Inside/IReadonlyReplicationProviderSignature.cs000644 001750 001750 00000001524 11520622640 036072 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Inside { public interface IReadonlyReplicationProviderSignature { long GetId(); byte[] GetSignature(); long GetCreated(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/IReplicationReference.cs000644 001750 001750 00000003260 11520622640 032674 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Foundation; namespace Db4objects.Drs.Inside { public interface IReplicationReference { IDrsUUID Uuid(); /// /// Must return the latests version of the object AND OF /// ALL COLLECTIONS IT REFERENCES IN ITS FIELDS because /// collections are treated as 2nd class objects /// (just like arrays) for Hibernate replication /// compatibility purposes. /// /// /// Must return the latests version of the object AND OF /// ALL COLLECTIONS IT REFERENCES IN ITS FIELDS because /// collections are treated as 2nd class objects /// (just like arrays) for Hibernate replication /// compatibility purposes. /// long Version(); object Object(); object Counterpart(); void SetCounterpart(object obj); void MarkForReplicating(bool flag); bool IsMarkedForReplicating(); void MarkForDeleting(); bool IsMarkedForDeleting(); void MarkCounterpartAsNew(); bool IsCounterpartNew(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/ReplicationReflector.cs000644 001750 001750 00000010601 11520622640 032607 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Generic; using Db4objects.Drs; using Db4objects.Drs.Db4o; namespace Db4objects.Drs.Inside { public class ReplicationReflector { private IInternalObjectContainer _container; private IReflector _reflector; public ReplicationReflector(IReplicationProvider providerA, IReplicationProvider providerB, IReflector reflector) { if (reflector == null) { if ((_container = ContainerFrom(providerA)) != null) { return; } if ((_container = ContainerFrom(providerB)) != null) { return; } } GenericReflector genericReflector = new GenericReflector(null, reflector == null ? Platform4.ReflectorForType(typeof(Db4objects.Drs.Inside.ReplicationReflector)) : reflector); Platform4.RegisterCollections(genericReflector); _reflector = genericReflector; } public virtual object[] ArrayContents(object array) { int[] dim = ArrayReflector().Dimensions(array); object[] result = new object[Volume(dim)]; ArrayReflector().Flatten(array, dim, 0, result, 0); //TODO Optimize add a visit(Visitor) method to ReflectArray or navigate the array to avoid copying all this stuff all the time. return result; } private int Volume(int[] dim) { int result = dim[0]; for (int i = 1; i < dim.Length; i++) { result = result * dim[i]; } return result; } public virtual IReflectClass ForObject(object obj) { return Reflector().ForObject(obj); } public virtual IReflectClass ForClass(Type clazz) { return Reflector().ForClass(clazz); } internal virtual IReflectClass GetComponentType(IReflectClass claxx) { return ArrayReflector().GetComponentType(claxx); } internal virtual int[] ArrayDimensions(object obj) { return ArrayReflector().Dimensions(obj); } public virtual object NewArrayInstance(IReflectClass componentType, int[] dimensions ) { return ArrayReflector().NewInstance(componentType, dimensions); } public virtual int ArrayShape(object[] a_flat, int a_flatElement, object a_shaped , int[] a_dimensions, int a_currentDimension) { return ArrayReflector().Shape(a_flat, a_flatElement, a_shaped, a_dimensions, a_currentDimension ); } public virtual bool IsValueType(IReflectClass clazz) { if (_container == null) { return clazz.IsImmutable(); } ClassMetadata classMetadata = _container.ClassMetadataForReflectClass(clazz); if (classMetadata == null) { return false; } return classMetadata.IsValueType(); } private IInternalObjectContainer ContainerFrom(IReplicationProvider provider) { if (!(provider is IDb4oReplicationProvider)) { return null; } IDb4oReplicationProvider db4oProvider = (IDb4oReplicationProvider)provider; IExtObjectContainer container = db4oProvider.GetObjectContainer(); if (!(container is IInternalObjectContainer)) { return null; } return (IInternalObjectContainer)container; } private IReflectArray ArrayReflector() { return Reflector().Array(); } // return _container.reflector().array(); private IReflector Reflector() { return _container == null ? _reflector : _container.Reflector(); } public virtual void CopyState(object to, object from) { IReflectClass fromClass = Reflector().ForObject(from); // FIXME: We need to get the classes parents fields copied too. foreach (IReflectField f in fromClass.GetDeclaredFields()) { if (f.IsStatic()) { continue; } f.Set(to, f.Get(from)); } } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/000755 001750 001750 00000000000 11520622066 030110 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/FieldIterators.cs000644 001750 001750 00000002730 11520622640 033357 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Reflect; namespace Db4objects.Drs.Inside.Traversal { public class FieldIterators { public static IEnumerator PersistentFields(IReflectClass claxx) { return Iterators.Filter(claxx.GetDeclaredFields(), new _IPredicate4_31()); } private sealed class _IPredicate4_31 : IPredicate4 { public _IPredicate4_31() { } public bool Match(object candidate) { IReflectField field = (IReflectField)candidate; if (field.IsStatic()) { return false; } if (field.IsTransient()) { return false; } if (Platform4.IsTransient(field.GetFieldType())) { return false; } return true; } } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/GenericTraverser.cs000644 001750 001750 00000010245 11520622640 033711 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Handlers.Array; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Inside; using Db4objects.Drs.Inside.Traversal; namespace Db4objects.Drs.Inside.Traversal { public class GenericTraverser : ITraverser { protected readonly ReplicationReflector _reflector; protected readonly ICollectionTraverser _collectionHandler; protected readonly IQueue4 _queue = new NonblockingQueue(); public GenericTraverser(ReplicationReflector reflector, ICollectionTraverser collectionHandler ) { _reflector = reflector; _collectionHandler = collectionHandler; } public virtual void TraverseGraph(object @object, IVisitor visitor) { QueueUpForTraversing(@object); while (true) { object next = _queue.Next(); if (next == null) { return; } TraverseObject(next, visitor); } } protected virtual void TraverseObject(object @object, IVisitor visitor) { if (!visitor.Visit(@object)) { return; } IReflectClass claxx = _reflector.ForObject(@object); TraverseAllFields(@object, claxx); } protected virtual void TraverseAllFields(object @object, IReflectClass claxx) { TraverseFields(@object, claxx); TraverseSuperclass(@object, claxx); } private void TraverseSuperclass(object @object, IReflectClass claxx) { IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } TraverseAllFields(@object, superclass); } private void TraverseFields(object @object, IReflectClass claxx) { IEnumerator fields = FieldIterators.PersistentFields(claxx); while (fields.MoveNext()) { IReflectField field = (IReflectField)fields.Current; object value = field.Get(@object); QueueUpForTraversing(value); } } protected virtual void TraverseCollection(object collection) { IEnumerator elements = _collectionHandler.IteratorFor(collection); //TODO Optimization: visit instead of flattening. while (elements.MoveNext()) { object element = elements.Current; if (element == null) { continue; } QueueUpForTraversing(element); } } protected virtual void TraverseArray(IReflectClass claxx, object array) { IEnumerator contents = ArrayHandler.Iterator(claxx, array); while (contents.MoveNext()) { QueueUpForTraversing(contents.Current); } } protected virtual void QueueUpForTraversing(object @object) { if (@object == null) { return; } IReflectClass claxx = _reflector.ForObject(@object); if (IsValueTypeOrArrayOfValueType(claxx) || Platform4.IsTransient(claxx)) { return; } if (_collectionHandler.CanHandleClass(claxx)) { TraverseCollection(@object); return; } if (claxx.IsArray()) { TraverseArray(claxx, @object); return; } QueueAdd(@object); } protected virtual void QueueAdd(object @object) { _queue.Add(@object); } protected virtual bool IsValueTypeOrArrayOfValueType(IReflectClass claxx) { // TODO Optimization: Compute this lazily in ReflectClass; if (_reflector.IsValueType(claxx)) { return true; } return claxx.IsArray() && _reflector.IsValueType(claxx.GetComponentType()); } public virtual void ExtendTraversalTo(object disconnected) { QueueUpForTraversing(disconnected); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/IVisitor.cs000644 001750 001750 00000001433 11520622640 032206 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Inside.Traversal { public interface IVisitor { bool Visit(object @object); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/ITraverser.cs000644 001750 001750 00000003325 11520622640 032526 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Inside.Traversal; namespace Db4objects.Drs.Inside.Traversal { public interface ITraverser { /// /// Traversal will only stop when visitor.visit(...) returns false, EVEN IN /// THE PRESENCE OF CIRCULAR REFERENCES. /// /// /// Traversal will only stop when visitor.visit(...) returns false, EVEN IN /// THE PRESENCE OF CIRCULAR REFERENCES. So it is up to the visitor to detect /// circular references if necessary. Transient fields are not visited. The /// fields of second class objects such as Strings and Dates are also not visited. /// void TraverseGraph(object @object, IVisitor visitor); /// Should only be called during a traversal. /// /// Should only be called during a traversal. Will traverse the graph /// for the received object too, using the current visitor. Used to /// extend the traversal to a possibly disconnected object graph. /// void ExtendTraversalTo(object disconnected); } } src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/ICollectionFlattener.cs000644 001750 001750 00000001631 11520622640 034430 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Drs.Inside.Traversal; namespace Db4objects.Drs.Inside.Traversal { public interface ICollectionFlattener : ICollectionTraverser { bool CanHandle(object obj); bool CanHandleClass(Type c); } } src/drs/Db4objects.Drs/Db4objects.Drs/Inside/Traversal/ICollectionTraverser.cs000644 001750 001750 00000001643 11520622640 034464 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Db4o.Reflect; namespace Db4objects.Drs.Inside.Traversal { public interface ICollectionTraverser { bool CanHandleClass(IReflectClass claxx); IEnumerator IteratorFor(object collection); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Inside/InstanceReplicationPreparer.cs000644 001750 001750 00000037341 11520622640 034141 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Reflect; using Db4objects.Drs; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; using Db4objects.Drs.Inside.Traversal; namespace Db4objects.Drs.Inside { internal class InstanceReplicationPreparer : IVisitor { private readonly IReplicationProviderInside _providerA; private readonly IReplicationProviderInside _providerB; private readonly IReplicationProvider _directionTo; private readonly IReplicationEventListener _listener; private readonly bool _isReplicatingOnlyDeletions; private readonly HashSet4 _uuidsProcessedInSession; private readonly ITraverser _traverser; private readonly ReplicationReflector _reflector; private readonly Db4objects.Drs.Inside.ICollectionHandler _collectionHandler; /// /// Purpose: handle circular references /// TODO Big Refactoring: Evolve this to handle ALL reference logic (!) and remove it from the providers. /// /// /// Purpose: handle circular references /// TODO Big Refactoring: Evolve this to handle ALL reference logic (!) and remove it from the providers. /// private readonly IdentitySet4 _objectsPreparedToReplicate = new IdentitySet4(100); /// /// key = object originated from one provider /// value = the counterpart ReplicationReference of the original object /// private IMap4 _counterpartRefsByOriginal = new IdentityHashtable4(100); private readonly ReplicationEventImpl _event; private readonly ObjectStateImpl _stateInA; private readonly ObjectStateImpl _stateInB; private object _obj; private object _referencingObject; private string _fieldName; internal InstanceReplicationPreparer(IReplicationProviderInside providerA, IReplicationProviderInside providerB, IReplicationProvider directionTo, IReplicationEventListener listener , bool isReplicatingOnlyDeletions, HashSet4 uuidsProcessedInSession, ITraverser traverser, ReplicationReflector reflector, Db4objects.Drs.Inside.ICollectionHandler collectionHandler) { _event = new ReplicationEventImpl(); _stateInA = _event._stateInProviderA; _stateInB = _event._stateInProviderB; _providerA = providerA; _providerB = providerB; _directionTo = directionTo; _listener = listener; _isReplicatingOnlyDeletions = isReplicatingOnlyDeletions; _uuidsProcessedInSession = uuidsProcessedInSession; _traverser = traverser; _reflector = reflector; _collectionHandler = collectionHandler; } private IReplicationProviderInside DirectionFrom() { return _providerA == _directionTo ? _providerB : _providerA; } public bool Visit(object obj) { if (DirectionFrom().IsSecondClassObject(obj)) { return false; } if (IsValueType(obj)) { return true; } if (_objectsPreparedToReplicate.Contains(obj)) { return false; } _objectsPreparedToReplicate.Add(obj); return PrepareObjectToBeReplicated(obj, null, null); } private bool IsValueType(object o) { return ReplicationPlatform.IsValueType(o); } private bool PrepareObjectToBeReplicated(object obj, object referencingObject, string fieldName) { //TODO Optimization: keep track of the peer we are traversing to avoid having to look in both. Logger4Support.LogIdentity(obj); _obj = obj; _referencingObject = referencingObject; _fieldName = fieldName; IReplicationReference refA = _providerA.ProduceReference(_obj, _referencingObject , _fieldName); IReplicationReference refB = _providerB.ProduceReference(_obj, _referencingObject , _fieldName); if (refA == null && refB == null) { throw new Exception(string.Empty + _obj.GetType() + " " + _obj + " must be stored in one of the databases being replicated." ); } //FIXME: Use db4o's standard for throwing exceptions. if (refA != null && refB != null) { throw new Exception(string.Empty + _obj.GetType() + " " + _obj + " cannot be referenced by both databases being replicated." ); } //FIXME: Use db4o's standard for throwing exceptions. IReplicationProviderInside owner = refA == null ? _providerB : _providerA; IReplicationReference ownerRef = refA == null ? refB : refA; IReplicationProviderInside other = Other(owner); IDrsUUID uuid = ownerRef.Uuid(); IReplicationReference otherRef = other.ProduceReferenceByUUID(uuid, _obj.GetType( )); if (refA == null) { refA = otherRef; } else { refB = otherRef; } //TODO for circular referenced object, otherRef should not be null in the subsequent pass. //But db4o always return null. A bug. check! if (otherRef == null) { //Object is only present in one ReplicationProvider. Missing in the other. Could have been deleted or never replicated. if (WasProcessed(uuid)) { IReplicationReference otherProcessedRef = other.ProduceReferenceByUUID(uuid, _obj .GetType()); if (otherProcessedRef != null) { ownerRef.SetCounterpart(otherProcessedRef.Object()); } return false; } MarkAsProcessed(uuid); long creationTime = ownerRef.Uuid().GetLongPart(); if (creationTime > owner.TimeStamps().From()) { //if it was created after the last time two ReplicationProviders were replicated it has to be treated as new. if (_isReplicatingOnlyDeletions) { return false; } return HandleNewObject(_obj, ownerRef, owner, other, _referencingObject, _fieldName , true, false); } else { // If it was created before the last time two ReplicationProviders were replicated it has to be treated as deleted. // No, not always, in a three-way replication setup it can also be new. return HandleMissingObjectInOther(_obj, ownerRef, owner, other, _referencingObject , _fieldName); } } if (_isReplicatingOnlyDeletions) { return false; } ownerRef.SetCounterpart(otherRef.Object()); otherRef.SetCounterpart(ownerRef.Object()); if (WasProcessed(uuid)) { return false; } //Has to be done AFTER the counterpart is set because object yet to be replicated might reference the current one, replicated previously. MarkAsProcessed(uuid); object objectA = refA.Object(); object objectB = refB.Object(); bool changedInA = _providerA.WasModifiedSinceLastReplication(refA); //System.out.println("changedInA = " + changedInA); bool changedInB = _providerB.WasModifiedSinceLastReplication(refB); //System.out.println("changedInB = " + changedInB); if (!changedInA && !changedInB) { return false; } bool conflict = false; if (changedInA && changedInB) { conflict = true; } if (changedInA && _directionTo == _providerA) { conflict = true; } if (changedInB && _directionTo == _providerB) { conflict = true; } object prevailing = _obj; _providerA.Activate(objectA); _providerB.Activate(objectB); _event.ResetAction(); _event.Conflict(conflict); _event._creationDate = TimeStampIdGenerator.IdToMilliseconds(uuid.GetLongPart()); _stateInA.SetAll(objectA, false, changedInA, TimeStampIdGenerator.IdToMilliseconds (ownerRef.Version())); _stateInB.SetAll(objectB, false, changedInB, TimeStampIdGenerator.IdToMilliseconds (otherRef.Version())); _listener.OnReplicate(_event); if (conflict) { if (!_event._actionWasChosen) { ThrowReplicationConflictException(); } if (_event._actionChosenState == null) { return false; } if (_event._actionChosenState == _stateInA) { prevailing = objectA; } if (_event._actionChosenState == _stateInB) { prevailing = objectB; } } else { if (_event._actionWasChosen) { if (_event._actionChosenState == _stateInA) { prevailing = objectA; } if (_event._actionChosenState == _stateInB) { prevailing = objectB; } if (_event._actionChosenState == null) { return false; } } else { if (changedInA) { prevailing = objectA; } if (changedInB) { prevailing = objectB; } } } IReplicationProviderInside prevailingPeer = prevailing == objectA ? _providerA : _providerB; if (_directionTo == prevailingPeer) { return false; } if (!conflict) { prevailingPeer.Activate(prevailing); } //Already activated if there was a conflict. if (prevailing != _obj) { otherRef.SetCounterpart(_obj); otherRef.MarkForReplicating(true); MarkAsNotProcessed(uuid); _traverser.ExtendTraversalTo(prevailing); } else { //Now we start traversing objects on the other peer! Is that cool or what? ;) ownerRef.MarkForReplicating(true); } return !_event._actionShouldStopTraversal; } private void MarkAsNotProcessed(IDrsUUID uuid) { _uuidsProcessedInSession.Remove(uuid); } private void MarkAsProcessed(IDrsUUID uuid) { if (_uuidsProcessedInSession.Contains(uuid)) { throw new Exception("illegal state"); } _uuidsProcessedInSession.Add(uuid); } private bool WasProcessed(IDrsUUID uuid) { return _uuidsProcessedInSession.Contains(uuid); } private IReplicationProviderInside Other(IReplicationProviderInside peer) { return peer == _providerA ? _providerB : _providerA; } private bool HandleMissingObjectInOther(object obj, IReplicationReference ownerRef , IReplicationProviderInside owner, IReplicationProviderInside other, object referencingObject , string fieldName) { bool isConflict = false; bool wasModified = owner.WasModifiedSinceLastReplication(ownerRef); if (wasModified) { isConflict = true; } if (_directionTo == other) { isConflict = true; } object prevailing = null; //by default, deletion prevails if (isConflict) { owner.Activate(obj); } _event.ResetAction(); _event.Conflict(isConflict); _event._creationDate = TimeStampIdGenerator.IdToMilliseconds(ownerRef.Uuid().GetLongPart ()); long modificationDate = TimeStampIdGenerator.IdToMilliseconds(ownerRef.Version()); if (owner == _providerA) { _stateInA.SetAll(obj, false, wasModified, modificationDate); _stateInB.SetAll(null, false, false, ObjectStateImpl.Unknown); } else { //owner == _providerB _stateInA.SetAll(null, false, false, ObjectStateImpl.Unknown); _stateInB.SetAll(obj, false, wasModified, modificationDate); } _listener.OnReplicate(_event); if (isConflict && !_event._actionWasChosen) { ThrowReplicationConflictException(); } if (_event._actionWasChosen) { if (_event._actionChosenState == null) { return false; } if (_event._actionChosenState == _stateInA) { prevailing = _stateInA.GetObject(); } if (_event._actionChosenState == _stateInB) { prevailing = _stateInB.GetObject(); } } if (prevailing == null) { //Deletion has prevailed. if (_directionTo == other) { return false; } ownerRef.MarkForDeleting(); return !_event._actionShouldStopTraversal; } bool needsToBeActivated = !isConflict; //Already activated if there was a conflict. return HandleNewObject(obj, ownerRef, owner, other, referencingObject, fieldName, needsToBeActivated, true); } private bool HandleNewObject(object obj, IReplicationReference ownerRef, IReplicationProviderInside owner, IReplicationProviderInside other, object referencingObject, string fieldName , bool needsToBeActivated, bool listenerAlreadyNotified) { if (_directionTo == owner) { return false; } if (needsToBeActivated) { owner.Activate(obj); } if (!listenerAlreadyNotified) { _event.ResetAction(); _event.Conflict(false); _event._creationDate = TimeStampIdGenerator.IdToMilliseconds(ownerRef.Uuid().GetLongPart ()); if (owner == _providerA) { _stateInA.SetAll(obj, true, false, ObjectStateImpl.Unknown); _stateInB.SetAll(null, false, false, ObjectStateImpl.Unknown); } else { _stateInA.SetAll(null, false, false, ObjectStateImpl.Unknown); _stateInB.SetAll(obj, true, false, ObjectStateImpl.Unknown); } if (_listener != null) { _listener.OnReplicate(_event); if (_event._actionWasChosen) { if (_event._actionChosenState == null) { return false; } if (_event._actionChosenState.GetObject() != obj) { return false; } } } } object counterpart = EmptyClone(owner, obj); ownerRef.SetCounterpart(counterpart); ownerRef.MarkForReplicating(true); IReplicationReference otherRef = other.ReferenceNewObject(counterpart, ownerRef, GetCounterpartRef(referencingObject), fieldName); otherRef.SetCounterpart(obj); PutCounterpartRef(obj, otherRef); if (_event._actionShouldStopTraversal) { return false; } return true; } private void ThrowReplicationConflictException() { throw new ReplicationConflictException("A replication conflict ocurred and the ReplicationEventListener, if any, did not choose which state should override the other." ); } private object EmptyClone(IReplicationProviderInside sourceProvider, object obj) { if (obj == null) { return null; } IReflectClass claxx = ReflectClass(obj); if (_reflector.IsValueType(claxx)) { throw new Exception("IllegalState"); } // if (claxx.isArray()) return arrayClone(obj, claxx, sourceProvider); //Copy arrayClone() from GenericReplicationSession if necessary. if (claxx.IsArray()) { throw new Exception("IllegalState"); } //Copy arrayClone() from GenericReplicationSession if necessary. if (_collectionHandler.CanHandleClass(claxx)) { return CollectionClone(sourceProvider, obj, claxx); } object result = claxx.NewInstance(); if (result == null) { throw new Exception("Unable to create a new instance of " + obj.GetType()); } //FIXME Use db4o's standard for throwing exceptions. return result; } private IReflectClass ReflectClass(object obj) { return _reflector.ForObject(obj); } private object CollectionClone(IReplicationProviderInside sourceProvider, object original, IReflectClass claxx) { return _collectionHandler.EmptyClone(sourceProvider, original, claxx); } private IReplicationReference GetCounterpartRef(object original) { return (IReplicationReference)_counterpartRefsByOriginal.Get(original); } private void PutCounterpartRef(object obj, IReplicationReference otherRef) { if (_counterpartRefsByOriginal.Get(obj) != null) { throw new Exception("illegal state"); } _counterpartRefsByOriginal.Put(obj, otherRef); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/IReplicationEvent.cs000644 001750 001750 00000004662 11520622640 030653 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs; namespace Db4objects.Drs { /// Defines an event class for the replication of an entity. /// Defines an event class for the replication of an entity. /// dRS 1.2 public interface IReplicationEvent { /// Does a conflict occur? /// true when a conflict occur bool IsConflict(); /// Overrides default replication behaviour with some state chosen by the user. /// /// Overrides default replication behaviour with some state chosen by the user. /// /// the ObjectState of the prevailing object or null if replication should ignore this object and not traverse to its referenced objects. /// void OverrideWith(IObjectState chosen); /// The ObjectState in provider A. /// The ObjectState in provider A. /// ObjectState in provider A IObjectState StateInProviderA(); /// The ObjectState in provider B. /// The ObjectState in provider B. /// ObjectState in provider B IObjectState StateInProviderB(); /// The time when the object is created in one provider. /// The time when the object is created in one provider. /// time when the object is created in one provider. long ObjectCreationDate(); /// The replication process will not traverse to objects referenced by the current one. /// /// The replication process will not traverse to objects referenced by the current one. /// void StopTraversal(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Replication.cs000644 001750 001750 00000010723 11520622640 027533 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Reflect; using Db4objects.Drs; using Db4objects.Drs.Inside; namespace Db4objects.Drs { /// Factory to create ReplicationSessions. /// Factory to create ReplicationSessions. /// 1.3 /// com.db4o.drs.hibernate.HibernateReplication /// /// IReplicationProvider /// IReplicationEventListener /// dRS 1.0 public class Replication { /// /// Begins a replication session between two ReplicationProviders without a /// ReplicationEventListener and with no Reflector provided. /// /// /// Begins a replication session between two ReplicationProviders without a /// ReplicationEventListener and with no Reflector provided. /// /// when conflicts occur /// IReplicationEventListener public static IReplicationSession Begin(IReplicationProvider providerA, IReplicationProvider providerB) { return Begin(providerA, providerB, null, null); } /// /// Begins a replication session between two ReplicationProviders using a /// ReplicationEventListener and with no Reflector provided. /// /// /// Begins a replication session between two ReplicationProviders using a /// ReplicationEventListener and with no Reflector provided. /// /// when conflicts occur /// IReplicationEventListener public static IReplicationSession Begin(IReplicationProvider providerA, IReplicationProvider providerB, IReplicationEventListener listener) { return Begin(providerA, providerB, listener, null); } /// /// Begins a replication session between two ReplicationProviders without a /// ReplicationEventListener and with a Reflector provided. /// /// /// Begins a replication session between two ReplicationProviders without a /// ReplicationEventListener and with a Reflector provided. /// /// when conflicts occur /// IReplicationEventListener public static IReplicationSession Begin(IReplicationProvider providerFrom, IReplicationProvider providerTo, IReflector reflector) { return Begin(providerFrom, providerTo, null, reflector); } /// /// Begins a replication session between two ReplicationProviders using a /// ReplicationEventListener and with a Reflector provided. /// /// /// Begins a replication session between two ReplicationProviders using a /// ReplicationEventListener and with a Reflector provided. /// /// when conflicts occur /// IReplicationEventListener public static IReplicationSession Begin(IReplicationProvider providerFrom, IReplicationProvider providerTo, IReplicationEventListener listener, IReflector reflector) { if (listener == null) { listener = new DefaultReplicationEventListener(); } ReplicationReflector rr = new ReplicationReflector(providerFrom, providerTo, reflector ); providerFrom.ReplicationReflector(rr); providerTo.ReplicationReflector(rr); return new GenericReplicationSession(providerFrom, providerTo, listener, reflector ); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/ReplicationConflictException.cs000644 001750 001750 00000002520 11520622640 033070 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Ext; namespace Db4objects.Drs { /// Thrown when a conflict occurs and no ReplicationEventListener is specified. /// /// Thrown when a conflict occurs and no ReplicationEventListener is specified. /// /// Albert Kwan /// Klaus Wuestefeld /// 1.2 /// IReplicationEventListener /// dRS 1.2 [System.Serializable] public class ReplicationConflictException : Db4oRecoverableException { public ReplicationConflictException(string message) : base(message) { } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/000755 001750 001750 00000000000 11520622070 027033 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/StackAnalyzer.cs000644 001750 001750 00000002043 11520622640 032137 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4objects.Drs.Foundation { public class StackAnalyzer { public static string MethodCallAboveAsString(Type clazz) { return "stack analyis NA"; } public static string MethodCallAsString(int depth) { return "stack analyis NA"; } // What? The class we are calling from is not available? Hm, we are not on Java. } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/Logger4.cs000644 001750 001750 00000003162 11520622640 030672 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Foundation; using Sharpen; namespace Db4objects.Drs.Foundation { /// Experiment field for future db4o logging. /// /// Experiment field for future db4o logging. /// This will become an interface in the future. /// It will also allow wrapping to Log4j /// For now we are just collecting requirments. /// We are not using log4j directly on purpose, so /// we can keep the footprint small for embedded /// devices /// public class Logger4 { public virtual void LogIdentity(object obj, string message) { if (obj == null) { Log(message + " [null]"); } Log(message + " " + obj.GetType() + " " + Runtime.IdentityHashCode(obj)); } public virtual void Log(string message) { return; Sharpen.Runtime.Out.WriteLine(StackAnalyzer.MethodCallAboveAsString(typeof(Logger4Support )) + " " + message); Sharpen.Runtime.Out.Flush(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/Logger4Support.cs000644 001750 001750 00000003011 11520622640 032260 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Foundation; namespace Db4objects.Drs.Foundation { /// Experiment field for future db4o logging. /// /// Experiment field for future db4o logging. /// This will become an interface in the future. /// It will also allow wrapping to Log4j /// For now we are just collecting requirments. /// We are not using log4j directly on purpose, so /// we can keep the footprint small for embedded /// devices /// public class Logger4Support { private static readonly Logger4 _logger = new Logger4(); public static void LogIdentity(object obj, string message) { _logger.LogIdentity(obj, message); } public static void LogIdentity(object obj) { LogIdentity(obj, string.Empty); } public static void Log(string str) { _logger.Log(str); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/Signatures.cs000644 001750 001750 00000002661 11520622640 031516 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections.Generic; using Db4objects.Drs.Foundation; namespace Db4objects.Drs.Foundation { public class Signatures { private readonly IDictionary _loidBySignature = new Dictionary(); private readonly IDictionary _signatureByLoid = new Dictionary(); public virtual void Add(Signature signature, long signatureLoid) { _loidBySignature[signature] = signatureLoid; _signatureByLoid[signatureLoid] = signature; } public virtual long LoidForSignature(Signature signature) { return _loidBySignature[signature]; } public virtual Signature SignatureForLoid(long signatureLoid) { return _signatureByLoid[signatureLoid]; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/Signature.cs000644 001750 001750 00000003572 11520622640 031335 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Text; using Db4objects.Db4o.Foundation; namespace Db4objects.Drs.Foundation { public class Signature { public readonly byte[] bytes; public Signature(byte[] bytes) { this.bytes = bytes; } public override bool Equals(object obj) { if (this == obj) { return true; } if (!(obj is Db4objects.Drs.Foundation.Signature)) { return false; } Db4objects.Drs.Foundation.Signature other = (Db4objects.Drs.Foundation.Signature) obj; return Arrays4.Equals(bytes, other.bytes); } public override int GetHashCode() { int hc = 0; for (int i = 0; i < bytes.Length; i++) { hc <<= 2; hc = hc ^ bytes[i]; } return hc; } public override string ToString() { return ToString(bytes); } public static string ToString(byte[] bytes) { return BytesToString(bytes); } private static string BytesToString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) { char c = (char)bytes[i]; sb.Append(c); } return sb.ToString(); } public virtual string AsString() { return BytesToString(bytes); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/IDrsUUID.cs000644 001750 001750 00000001455 11520622640 030722 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Foundation { public interface IDrsUUID { long GetLongPart(); byte[] GetSignaturePart(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/TimeStamps.cs000644 001750 001750 00000002115 11520622640 031452 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Foundation { public class TimeStamps { private long _from; private long _commit; public TimeStamps(long from, long commit) { this._from = from; this._commit = commit; } public virtual long To() { return _commit - 1; } public virtual long From() { return _from; } public virtual long Commit() { return _commit; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/LinePrinter.cs000644 001750 001750 00000002721 11520622640 031622 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.IO; using Db4objects.Drs.Foundation; namespace Db4objects.Drs.Foundation { public abstract class LinePrinter { private sealed class _LinePrinter_9 : LinePrinter { public _LinePrinter_9() { } public override void Println(string str) { } } public static readonly LinePrinter NullPrinter = new _LinePrinter_9(); // do nothing public abstract void Println(string str); public static LinePrinter ForPrintStream(TextWriter ps) { return new _LinePrinter_20(ps); } private sealed class _LinePrinter_20 : LinePrinter { public _LinePrinter_20(TextWriter ps) { this.ps = ps; } public override void Println(string str) { ps.WriteLine(str); } private readonly TextWriter ps; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/Foundation/DrsUUIDImpl.cs000644 001750 001750 00000003672 11520622640 031436 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Ext; using Db4objects.Drs.Foundation; namespace Db4objects.Drs.Foundation { public class DrsUUIDImpl : IDrsUUID { private readonly Signature _signature; private readonly long _longPart; public DrsUUIDImpl(Signature signature, long longPart) { _signature = signature; _longPart = longPart; } public DrsUUIDImpl(byte[] signature, long longPart) : this(new Signature(signature ), longPart) { } public DrsUUIDImpl(Db4oUUID db4oUUID) : this(db4oUUID.GetSignaturePart(), db4oUUID .GetLongPart()) { } public virtual long GetLongPart() { return _longPart; } public virtual byte[] GetSignaturePart() { return _signature.bytes; } public override bool Equals(object obj) { if (!(obj is Db4objects.Drs.Foundation.DrsUUIDImpl)) { return false; } Db4objects.Drs.Foundation.DrsUUIDImpl other = (Db4objects.Drs.Foundation.DrsUUIDImpl )obj; return _longPart == other._longPart && _signature.Equals(other._signature); } public override int GetHashCode() { return ((int)_longPart) ^ _signature.GetHashCode(); } public override string ToString() { return "longpart " + _longPart + " signature " + _signature.AsString(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/IReplicationSession.cs000644 001750 001750 00000013526 11520622640 031214 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Drs; namespace Db4objects.Drs { /// Execute a round of replication between two ReplicationProviders. /// /// Execute a round of replication between two ReplicationProviders. ///

/// Sample code of using ReplicationSession: ///

	/// ReplicationSession session = Replication.begin(objectContainer1, objectContainer2);
	/// session.replicate(object);
	/// session.commit();
	/// session.close();
	/// 
///
/// 1.2 /// Replication /// dRS 1.0 public interface IReplicationSession { /// Closes this session and frees used resources. /// /// Closes this session and frees used resources. Sessions that were opened /// during the creation of ReplicationProviders will be closed as well. ///

/// Hibernate Sessions created from Hibernate Configurations will be closed. /// db4o ObjectContainers will remain open. /// /// if the session is still active (neither commitReplicationTransaction() nor rollback is called). /// void Close(); ///

/// Commits replication changes to both ReplicationProviders and marks the /// involved ReplicationProviders to be "clean" against each other - to contain /// no modified objects. /// /// /// Commits replication changes to both ReplicationProviders and marks the /// involved ReplicationProviders to be "clean" against each other - to contain /// no modified objects. /// void Commit(); /// /// Returns the ReplicationProvider representing the first persistence /// system passed as a parameter when the replication session was instantiated. /// /// /// Returns the ReplicationProvider representing the first persistence /// system passed as a parameter when the replication session was instantiated. /// /// the first persistence system IReplicationProvider ProviderA(); /// /// Returns the ReplicationProvider representing the second persistence /// system passed as a parameter when the replication session was instantiated. /// /// /// Returns the ReplicationProvider representing the second persistence /// system passed as a parameter when the replication session was instantiated. /// /// the second persistence system IReplicationProvider ProviderB(); /// /// Replicates an individual object and traverses to member objects as long as /// members are new or modified since the last time the two ReplicationProviders /// were replicated. /// /// /// Replicates an individual object and traverses to member objects as long as /// members are new or modified since the last time the two ReplicationProviders /// were replicated. /// /// the object to be replicated. /// IReplicationEventListener void Replicate(object obj); /// Replicates all deletions between the two providers. /// /// Replicates all deletions between the two providers. /// Cascade delete is disabled, regardless the user's settings. ///

/// If the deletion violates referential integrity, exception will be thrown. /// You can use the dRS replication callback to check whether the object to /// be deleted violates referential integrity. If so, you can stop traversal. /// /// the Class that you want to delete void ReplicateDeletions(Type extent); ///

Rollbacks all changes done during the replication session. /// /// Rollbacks all changes done during the replication session. This call /// guarantees the changes will not be applied to the underlying databases. The /// state of the objects involved in the replication is undefined. /// Both ReplicationProviders may still contain cached references of touched objects. ///

/// To restart replication, it is recommended to reopen both involved /// ReplicationProviders and to start a new ReplicationSession. /// void Rollback(); ///

Sets the direction of replication. /// /// Sets the direction of replication. By default, if this method is not called, replication is bidirectional, /// which means the newer copy of the object is copied to the other provider.. ///

If you want to force unidirectional replication, call this method before calling /// Replicate(object) /// . /// /// objects in this provider will not be changed. /// objects will be copied to this provider if copies in "from" is newer /// void SetDirection(IReplicationProvider from, IReplicationProvider to); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Db4objects.Drs/IReplicationProvider.cs000644 001750 001750 00000004746 11520622640 031367 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o; namespace Db4objects.Drs { ///

Facade for persistence systems that provide replication support. /// /// Facade for persistence systems that provide replication support. /// Interacts with another ReplicationProvider and a ReplicationSession /// to allows replication of objects between two ReplicationProviders. ///

///

To create an instance of this class, use the methods of /// Replication /// . /// /// IReplicationSession /// Replication /// dRS 1.0 public interface IReplicationProvider { ///

Returns newly created objects and changed objects since last replication with the opposite provider. /// /// Returns newly created objects and changed objects since last replication with the opposite provider. /// /// newly created objects and changed objects since last replication with the opposite provider. /// IObjectSet ObjectsChangedSinceLastReplication(); /// Returns newly created objects and changed objects since last replication with the opposite provider. /// /// Returns newly created objects and changed objects since last replication with the opposite provider. /// /// the type of objects interested /// newly created objects and changed objects of the type specified in the clazz parameter since last replication /// IObjectSet ObjectsChangedSinceLastReplication(Type clazz); void ReplicationReflector(Db4objects.Drs.Inside.ReplicationReflector replicationReflector ); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Properties/000755 001750 001750 00000000000 11520622070 024347 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs/Properties/AssemblyInfo.cs000644 001750 001750 00000002400 11520622640 027270 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTitle("dRS")] [assembly: AssemblyDescription("Db4objects.Drs 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: AssemblyVersion("8.0.184.15484")] [assembly: CLSCompliant(true)]db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/000755 001750 001750 00000000000 11520622054 023316 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests-2008.csproj000644 001750 001750 00000023765 11520622054 030757 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {C0BA12AD-54B4-43B0-A570-0299F6253AC7} Exe Properties Db4objects.Drs.Tests Db4objects.Drs.Tests v3.5 512 Db4objects.Drs.Tests.Db4oDrsTestSuiteBuilder true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 3.5 3.5 3.5 {9FA8178A-3E77-42C5-A252-6690EA9BA257} Db4objects.Db4o.CS-2008 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3} Db4oUnit.Extensions-2008 {8F82F8B0-95B6-4553-BDA8-BD9A954E682F} Db4oUnit-2008 {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6} Db4objects.Drs-2008 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/000755 001750 001750 00000000000 11520622056 024606 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/000755 001750 001750 00000000000 11520622066 030422 5ustar00directhexdirecthex000000 000000 src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/ReplicationTestPlatform.cs000644 001750 001750 00000001556 11520622640 035515 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; namespace Db4objects.Drs.Tests { class ReplicationTestPlatform { public static IEnumerator Adapt(IEnumerator enumerator) { return enumerator; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/ListTest.cs000644 001750 001750 00000011771 11520622640 032531 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ListTest : DrsTestCase { public virtual void Test() { ActualTest(); } protected virtual void ActualTest() { StoreListToProviderA(); ReplicateAllToProviderBFirstTime(); ModifyInProviderB(); ReplicateAllStep2(); AddElementInProviderA(); ReplicateHolderStep3(); } private void StoreListToProviderA() { ListHolder lh = CreateHolder(); ListContent lc1 = new ListContent("c1"); ListContent lc2 = new ListContent("c2"); lh.Add(lc1); lh.Add(lc2); A().Provider().StoreNew(lh); A().Provider().Commit(); EnsureContent(A(), new string[] {"h1"}, new string[] {"c1", "c2"}); } protected virtual ListHolder CreateHolder() { ListHolder lh = new ListHolder("h1"); lh.SetList(new ArrayList()); return lh; } private void ReplicateAllToProviderBFirstTime() { ReplicateAll(A().Provider(), B().Provider()); EnsureContent(A(), new string[] {"h1"}, new string[] {"c1", "c2"}); EnsureContent(B(), new string[] {"h1"}, new string[] {"c1", "c2"}); } private void ModifyInProviderB() { ListHolder lh = (ListHolder) GetOneInstance (B(), typeof (ListHolder)); lh.SetName("h2"); IEnumerator itor = lh.GetList().GetEnumerator(); itor.MoveNext(); ListContent lc1 = (ListContent) itor.Current; itor.MoveNext(); ListContent lc2 = (ListContent) itor.Current; lc1.SetName("co1"); lc2.SetName("co2"); B().Provider().Update(lc1); B().Provider().Update(lc2); B().Provider().Update(lh.GetList()); B().Provider().Update(lh); B().Provider().Commit(); EnsureContent(B(), new string[] {"h2"}, new string[] {"co1", "co2"}); } private void ReplicateAllStep2() { ReplicateAll(B().Provider(), A().Provider()); EnsureContent(B(), new string[] {"h2"}, new string[] {"co1", "co2"}); EnsureContent(A(), new string[] {"h2"}, new string[] {"co1", "co2"}); } private void AddElementInProviderA() { ListHolder lh = (ListHolder) GetOneInstance (A(), typeof (ListHolder)); lh.SetName("h3"); ListContent lc3 = new ListContent("co3"); A().Provider().StoreNew(lc3); lh.GetList().Add(lc3); A().Provider().Update(lh.GetList()); A().Provider().Update(lh); A().Provider().Commit(); EnsureContent(A(), new string[] {"h3"}, new string[] {"co1", "co2", "co3"}); } private void ReplicateHolderStep3() { ReplicateClass(A().Provider(), B().Provider(), typeof (ListHolder) ); EnsureContent(A(), new string[] {"h3"}, new string[] {"co1", "co2", "co3"}); EnsureContent(B(), new string[] {"h3"}, new string[] {"co1", "co2", "co3"}); } private void EnsureContent(IDrsProviderFixture fixture, string[] holderNames, string[] contentNames) { int holderCount = holderNames.Length; EnsureInstanceCount(fixture, typeof (ListHolder), holderCount); int i = 0; IEnumerator objectSet = fixture.Provider().GetStoredObjects(typeof (ListHolder)).GetEnumerator(); while (objectSet.MoveNext()) { ListHolder lh = (ListHolder) objectSet.Current; Assert.AreEqual(holderNames[i], lh.GetName()); IEnumerator itor = lh.GetList().GetEnumerator(); int idx = 0; while (itor.MoveNext()) { Assert.AreEqual(contentNames[idx], ((ListContent) itor.Current).GetName()); idx++; } } } } }db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Db4oDrsTestSuite.cs000644 001750 001750 00000002361 11520622640 034064 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Drs.Tests.Dotnet; namespace Db4objects.Drs.Tests { partial class Db4oDrsTestSuite { protected override Type[] TestCases() { return Concat(PlatformSpecificTestCases(), Concat(base.TestCases(), SpecificTestCases())); } private Type[] PlatformSpecificTestCases() { return new Type[] { typeof(Regression.DelegateTestCase), typeof(Regression.GenericListTestSuite), typeof(Regression.GenericDictionaryTestCase), typeof(GenericEqualityComparerTestCase), }; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Foundation/000755 001750 001750 00000000000 11520622044 032524 5ustar00directhexdirecthex000000 000000 Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Foundation/ObjectSetCollection4FacadeTestCase.cs000644 001750 001750 00000004025 11520622640 041501 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Foundation { public class ObjectSetCollection4FacadeTestCase : Db4oUnit.ITestCase { public static void Main(string[] args) { new Db4oUnit.ConsoleTestRunner(typeof(Db4objects.Drs.Tests.Foundation.ObjectSetCollection4FacadeTestCase) ).Run(); } public virtual void TestEmpty() { Db4objects.Drs.Foundation.ObjectSetCollection4Facade facade = new Db4objects.Drs.Foundation.ObjectSetCollection4Facade (new Db4objects.Db4o.Foundation.Collection4()); Db4oUnit.Assert.IsFalse(facade.HasNext()); Db4oUnit.Assert.IsFalse(facade.HasNext()); } public virtual void TestIteration() { Db4objects.Db4o.Foundation.Collection4 collection = new Db4objects.Db4o.Foundation.Collection4 (); collection.Add("bar"); collection.Add("foo"); Db4objects.Drs.Foundation.ObjectSetCollection4Facade facade = new Db4objects.Drs.Foundation.ObjectSetCollection4Facade (collection); Db4oUnit.Assert.IsTrue(facade.HasNext()); Db4oUnit.Assert.AreEqual("bar", facade.Next()); Db4oUnit.Assert.IsTrue(facade.HasNext()); Db4oUnit.Assert.AreEqual("foo", facade.Next()); Db4oUnit.Assert.IsFalse(facade.HasNext()); facade.Reset(); Db4oUnit.Assert.AreEqual("bar", facade.Next()); Db4oUnit.Assert.AreEqual("foo", facade.Next()); Db4oUnit.Assert.IsFalse(facade.HasNext()); } } } src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/GenericEqualityComparerTestCase.cs000644 001750 001750 00000002634 11520622640 037114 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Text; using Db4objects.Db4o; using Db4oUnit; namespace Db4objects.Drs.Tests { class GenericEqualityComparerTestCase : DrsTestCase { public class Item { public IEqualityComparer comparer; public Item(IEqualityComparer comparer) { this.comparer = comparer; } } public void Test() { A().Provider().StoreNew(new Item(EqualityComparer.Default)); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider()); IObjectSet found = B().Provider().GetStoredObjects(typeof(Item)); Assert.AreEqual(1, found.Count); Item item = (Item) found[0]; Assert.IsNotNull(item.comparer); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/DelegatingList.cs000644 001750 001750 00000004631 11520622640 033652 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; namespace Db4objects.Drs.Tests { public class DelegatingList : IList { private IList _delegate; public DelegatingList(IList @delegate) { _delegate = @delegate; } #region IList Members public int Add(object value) { return _delegate.Add(value); } public void Clear() { throw new NotImplementedException(); } public bool Contains(object value) { throw new NotImplementedException(); } public int IndexOf(object value) { throw new NotImplementedException(); } public void Insert(int index, object value) { throw new NotImplementedException(); } public bool IsFixedSize { get { throw new NotImplementedException(); } } public bool IsReadOnly { get { throw new NotImplementedException(); } } public void Remove(object value) { throw new NotImplementedException(); } public void RemoveAt(int index) { throw new NotImplementedException(); } public object this[int index] { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } #endregion #region ICollection Members public void CopyTo(Array array, int index) { throw new NotImplementedException(); } public int Count { get { throw new NotImplementedException(); } } public bool IsSynchronized { get { throw new NotImplementedException(); } } public object SyncRoot { get { throw new NotImplementedException(); } } #endregion #region IEnumerable Members public IEnumerator GetEnumerator() { return _delegate.GetEnumerator(); } #endregion } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/000755 001750 001750 00000000000 11520622070 032535 5ustar00directhexdirecthex000000 000000 src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/GenericListTestSuite.cs000644 001750 001750 00000004335 11520622640 037077 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using Db4objects.Db4o.Foundation; using Db4oUnit.Fixtures; namespace Db4objects.Drs.Tests.Regression { class GenericListTestSuite : FixtureBasedTestSuite { public override Type[] TestUnits() { return new Type[] { typeof(GenericListTestCase) }; } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SubjectFixtureProvider(GenerateLists()), }; } private IEnumerable GenerateLists() { IEnumerable tenStrings = GenerateStrings(10); yield return new List(); yield return new List(tenStrings); yield return new ArrayList(); yield return new ArrayList(new List(tenStrings)); yield return new LinkedList(tenStrings); yield return new LinkedList(); yield return new LinkedList(Range(0, 10)); yield return new List(GenerateContainers(tenStrings)); } private IEnumerable GenerateContainers(IEnumerable names) { foreach (string name in names) { yield return new Container(name, null); } } private static IEnumerable Range(int begin, int end) { for (int i=begin; i GenerateStrings(int count) { if (count < 0) throw new ArgumentOutOfRangeException("count"); for (int i = 0; i < count; i++) { yield return "string " + i; } } } }src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/GenericCollectionTestCaseBase.cs000644 001750 001750 00000003536 11520622640 040636 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using Db4objects.Drs.Tests; using Db4objects.Drs.Inside; using Db4objects.Db4o; using Db4oUnit; namespace Db4objects.Drs.Tests.Regression { abstract class GenericCollectionTestCaseBase : DrsTestCase { public void Test() { StoreToProviderA(); ReplicateAllToProviderB(); EnsureContent(B().Provider()); } private void StoreToProviderA() { ITestableReplicationProviderInside providerA = A().Provider(); providerA.StoreNew(CreateItem()); providerA.Commit(); } private void ReplicateAllToProviderB() { ReplicateAll(A().Provider(), B().Provider()); } public object QueryItem(ITestableReplicationProviderInside provider, Type type) { IObjectSet result = provider.GetStoredObjects(type); Assert.AreEqual(1, result.Count); return result.Next(); } public abstract object CreateItem(); public abstract void EnsureContent(ITestableReplicationProviderInside provider); } } src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/GenericListTestCase.cs000644 001750 001750 00000003414 11520622640 036656 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using Db4objects.Drs.Inside; using Db4oUnit; using Db4oUnit.Fixtures; namespace Db4objects.Drs.Tests.Regression { class GenericListTestCase : GenericCollectionTestCaseBase { public class RootContainer : Container { public RootContainer(string name, IEnumerable items) : base(name, items) { } } public override object CreateItem() { return new RootContainer("ROOT", (IEnumerable) SubjectFixtureProvider.Value()); } public override void EnsureContent(ITestableReplicationProviderInside provider) { Container replicated = (Container) QueryItem(provider, typeof(RootContainer)); Container expected = (Container) CreateItem(); Assert.AreSame(expected.GetType(), replicated.GetType()); Assert.AreNotSame(expected, replicated); Assert.AreEqual(expected._name, replicated._name); Iterator4Assert.AreEqual(expected._items.GetEnumerator(), replicated._items.GetEnumerator()); } } } src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/Container.cs000644 001750 001750 00000002412 11520622640 034731 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; namespace Db4objects.Drs.Tests.Regression { public class Container { public string _name; public IEnumerable _items; public Container(string name, IEnumerable items) { _name = name; _items = items; } public override string ToString() { return string.Format("Container({0})", _name); } public override bool Equals(object obj) { Container other = obj as Container; if (null == other) return false; return _name == other._name; } public override int GetHashCode() { return _name.GetHashCode(); } } }src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/DelegateTestCase.cs000644 001750 001750 00000006152 11520622640 036162 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using Db4objects.Db4o; using Db4oUnit; namespace Db4objects.Drs.Tests.Regression { class DelegateTestCase : DrsTestCase { public class Item { public event EventHandler Foo; public string Value; public object untyped; public object[] array; public Item(string value) { Value = value; } public int HandlerCount { get { if (Foo == null) return 0; return Foo.GetInvocationList().Length; } } } public void TestDelegateFields() { Item item = new Item("the item"); item.Foo += delegate { }; item.untyped = StringAction(); item.array = new object[] { StringAction() }; Item replicated = Replicate(item); Assert.IsNotNull(replicated); Assert.AreEqual(item.Value, replicated.Value); Assert.AreEqual(0, replicated.HandlerCount); Assert.IsNull(replicated.untyped); Assert.AreEqual(1, replicated.array.Length); Assert.IsNull(replicated.array[0]); } private static Action StringAction() { return new System.Action(Console.WriteLine); } public class DictionaryHolder { public Dictionary> actionDictionary; public object untyped; public object[] array; } public void TestDictionaryHolder() { DictionaryHolder item = new DictionaryHolder(); item.actionDictionary = NewActionDictionary(); item.untyped = NewActionDictionary(); item.array = new object[] { NewActionDictionary() }; DictionaryHolder replicated = Replicate(item); Assert.IsNotNull(replicated.actionDictionary); Assert.IsNotNull(replicated.untyped); Assert.IsNotNull(replicated.array[0]); } private static Dictionary> NewActionDictionary() { Dictionary> d = new Dictionary>(); d["print"] = StringAction(); return d; } private T Replicate(T item) { StoreToA(item); ReplicateAll(); return QueryReplicated(); } private T QueryReplicated() { IObjectSet found = B().Provider().GetStoredObjects(typeof(T)); Assert.AreEqual(1, found.Count); return (T)found.Next(); } private void ReplicateAll() { ReplicateAll(A().Provider(), B().Provider()); } private void StoreToA(object item) { A().Provider().StoreNew(item); A().Provider().Commit(); } } } src/drs/Db4objects.Drs.Tests/native/Db4objects.Drs.Tests/Regression/GenericDictionaryTestCase.cs000644 001750 001750 00000004103 11520622640 040044 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Collections; using Db4objects.Drs.Inside; using Db4oUnit; namespace Db4objects.Drs.Tests.Regression { class GenericDictionaryTestCase : GenericCollectionTestCaseBase { public class Container { public string _name; public IDictionary _items; public Container(string name, IDictionary items) { _name = name; _items = items; } } public override object CreateItem() { Dictionary dictionary = new Dictionary(); for (int i = 0; i < 10; i++) { dictionary.Add("Key " + i, i); } Container container = new Container("Dictionary Item", dictionary); return container; } public override void EnsureContent(ITestableReplicationProviderInside provider) { Container replicated = (Container)QueryItem(provider, typeof(Container)); Container expected = (Container)CreateItem(); Assert.AreNotSame(expected, replicated); Assert.AreEqual(expected._name, replicated._name); Iterator4Assert.AreEqual(expected._items.GetEnumerator(), replicated._items.GetEnumerator()); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Sharpen.Util/000755 001750 001750 00000000000 11520622056 027122 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/native/Sharpen.Util/IdentityHashMap.cs000644 001750 001750 00000002403 11520622640 032502 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; namespace Sharpen.Util { public class IdentityHashMap : Hashtable { public IdentityHashMap() : base(EqualityComparer.Default) { } public override void Add(object key, object value) { this[key] = value; } class EqualityComparer : IEqualityComparer { public static readonly IEqualityComparer Default = new EqualityComparer(); public bool Equals(object x, object y) { return x == y; } public int GetHashCode(object obj) { return Sharpen.Runtime.IdentityHashCode(obj); } } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests-2008.sln000644 001750 001750 00000006664 11520622054 030252 0ustar00directhexdirecthex000000 000000  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-2008", "..\..\Db4objects.Db4o\Db4objects.Db4o-2008.csproj", "{600CD3BF-2ED2-4183-87F7-ADD78A968AE0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit-2008", "..\..\Db4oUnit\Db4oUnit-2008.csproj", "{8F82F8B0-95B6-4553-BDA8-BD9A954E682F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit.Extensions-2008", "..\..\Db4oUnit.Extensions\Db4oUnit.Extensions-2008.csproj", "{9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Drs-2008", "..\Db4objects.Drs\Db4objects.Drs-2008.csproj", "{B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Drs.Tests-2008", "Db4objects.Drs.Tests-2008.csproj", "{C0BA12AD-54B4-43B0-A570-0299F6253AC7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.CS-2008", "..\..\Db4objects.Db4o.CS\Db4objects.Db4o.CS-2008.csproj", "{9FA8178A-3E77-42C5-A252-6690EA9BA257}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.Build.0 = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.Build.0 = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.Build.0 = Release|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8BF0B55-AB4E-4335-80D1-DEDAD410FAD6}.Release|Any CPU.Build.0 = Release|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0BA12AD-54B4-43B0-A570-0299F6253AC7}.Release|Any CPU.Build.0 = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Debug|Any CPU.Build.0 = Debug|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.ActiveCfg = Release|Any CPU {9FA8178A-3E77-42C5-A252-6690EA9BA257}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/000755 001750 001750 00000000000 11520622070 027127 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ReplicationEventTest.cs000644 001750 001750 00000016571 11520622640 033606 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ReplicationEventTest : DrsTestCase { private static readonly string InA = "in A"; private static readonly string ModifiedInA = "modified in A"; private static readonly string ModifiedInB = "modified in B"; private void EnsureNames(IDrsProviderFixture fixture, string parentName, string childName ) { EnsureOneInstanceOfParentAndChild(fixture); SPCParent parent = (SPCParent)GetOneInstance(fixture, typeof(SPCParent)); if (!parent.GetName().Equals(parentName)) { Sharpen.Runtime.Out.WriteLine("expected = " + parentName); Sharpen.Runtime.Out.WriteLine("actual = " + parent.GetName()); } Assert.AreEqual(parent.GetName(), parentName); Assert.AreEqual(childName, parent.GetChild().GetName()); } private void EnsureNotExist(ITestableReplicationProviderInside provider, Type type ) { Assert.IsTrue(!provider.GetStoredObjects(type).GetEnumerator().MoveNext()); } private void EnsureOneInstanceOfParentAndChild(IDrsProviderFixture fixture) { EnsureOneInstance(fixture, typeof(SPCParent)); EnsureOneInstance(fixture, typeof(SPCChild)); } private void ModifyInProviderA() { SPCParent parent = (SPCParent)GetOneInstance(A(), typeof(SPCParent)); parent.SetName(ModifiedInA); SPCChild child = parent.GetChild(); child.SetName(ModifiedInA); A().Provider().Update(parent); A().Provider().Update(child); A().Provider().Commit(); EnsureNames(A(), ModifiedInA, ModifiedInA); } private void ModifyInProviderB() { SPCParent parent = (SPCParent)GetOneInstance(B(), typeof(SPCParent)); parent.SetName(ModifiedInB); SPCChild child = parent.GetChild(); child.SetName(ModifiedInB); B().Provider().Update(parent); B().Provider().Update(child); B().Provider().Commit(); EnsureNames(B(), ModifiedInB, ModifiedInB); } private void ReplicateAllToProviderBFirstTime() { ReplicateAll(A().Provider(), B().Provider()); EnsureNames(A(), InA, InA); EnsureNames(B(), InA, InA); } private void StoreParentAndChildToProviderA() { SPCChild child = new SPCChild(InA); SPCParent parent = new SPCParent(child, InA); A().Provider().StoreNew(parent); A().Provider().Commit(); EnsureNames(A(), InA, InA); } public virtual void TestNewObject() { StoreParentAndChildToProviderA(); ReplicationEventTest.BooleanClosure invoked = new ReplicationEventTest.BooleanClosure (false); IReplicationEventListener listener = new _IReplicationEventListener_203(invoked); ReplicateAll(A().Provider(), B().Provider(), listener); Assert.IsTrue(invoked.GetValue()); EnsureNames(A(), InA, InA); EnsureNotExist(B().Provider(), typeof(SPCParent)); EnsureNotExist(B().Provider(), typeof(SPCChild)); } private sealed class _IReplicationEventListener_203 : IReplicationEventListener { public _IReplicationEventListener_203(ReplicationEventTest.BooleanClosure invoked ) { this.invoked = invoked; } public void OnReplicate(IReplicationEvent @event) { invoked.SetValue(true); IObjectState stateA = @event.StateInProviderA(); IObjectState stateB = @event.StateInProviderB(); Assert.IsTrue(stateA.IsNew()); Assert.IsTrue(!stateB.IsNew()); Assert.IsNotNull(stateA.GetObject()); Assert.IsNull(stateB.GetObject()); @event.OverrideWith(null); } private readonly ReplicationEventTest.BooleanClosure invoked; } public virtual void TestNoAction() { StoreParentAndChildToProviderA(); ReplicateAllToProviderBFirstTime(); ModifyInProviderB(); IReplicationEventListener listener = new _IReplicationEventListener_234(); //do nothing ReplicateAll(B().Provider(), A().Provider(), listener); EnsureNames(A(), ModifiedInB, ModifiedInB); EnsureNames(B(), ModifiedInB, ModifiedInB); } private sealed class _IReplicationEventListener_234 : IReplicationEventListener { public _IReplicationEventListener_234() { } public void OnReplicate(IReplicationEvent @event) { } } public virtual void TestOverrideWhenConflicts() { StoreParentAndChildToProviderA(); ReplicateAllToProviderBFirstTime(); //introduce conflicts ModifyInProviderA(); ModifyInProviderB(); IReplicationEventListener listener = new _IReplicationEventListener_254(); ReplicateAll(A().Provider(), B().Provider(), listener); EnsureNames(A(), ModifiedInB, ModifiedInB); EnsureNames(B(), ModifiedInB, ModifiedInB); } private sealed class _IReplicationEventListener_254 : IReplicationEventListener { public _IReplicationEventListener_254() { } public void OnReplicate(IReplicationEvent @event) { Assert.IsTrue(@event.IsConflict()); if (@event.IsConflict()) { @event.OverrideWith(@event.StateInProviderB()); } } } public virtual void TestOverrideWhenNoConflicts() { StoreParentAndChildToProviderA(); ReplicateAllToProviderBFirstTime(); ModifyInProviderB(); IReplicationEventListener listener = new _IReplicationEventListener_274(); ReplicateAll(B().Provider(), A().Provider(), listener); EnsureNames(A(), InA, InA); EnsureNames(B(), InA, InA); } private sealed class _IReplicationEventListener_274 : IReplicationEventListener { public _IReplicationEventListener_274() { } public void OnReplicate(IReplicationEvent @event) { Assert.IsTrue(!@event.IsConflict()); @event.OverrideWith(@event.StateInProviderB()); } } public virtual void TestStopTraversal() { StoreParentAndChildToProviderA(); ReplicateAllToProviderBFirstTime(); //introduce conflicts ModifyInProviderA(); ModifyInProviderB(); IReplicationEventListener listener = new _IReplicationEventListener_295(); ReplicateAll(A().Provider(), B().Provider(), listener); EnsureNames(A(), ModifiedInA, ModifiedInA); EnsureNames(B(), ModifiedInB, ModifiedInB); } private sealed class _IReplicationEventListener_295 : IReplicationEventListener { public _IReplicationEventListener_295() { } public void OnReplicate(IReplicationEvent @event) { Assert.IsTrue(@event.IsConflict()); @event.OverrideWith(null); } } internal class BooleanClosure { private bool value; public BooleanClosure(bool value) { this.value = value; } internal virtual void SetValue(bool v) { value = v; } public virtual bool GetValue() { return value; } } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/TransparentActivationTestCase.cs000644 001750 001750 00000003642 11520622640 035366 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.TA; using Db4objects.Drs.Db4o; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; using Sharpen; namespace Db4objects.Drs.Tests { public class TransparentActivationTestCase : DrsTestCase { protected override void Configure(IConfiguration config) { config.Add(new TransparentActivationSupport()); } /// public virtual void Test() { ActivatableItem item = new ActivatableItem("foo"); A().Provider().StoreNew(item); A().Provider().Commit(); if (A().Provider() is IDb4oReplicationProvider) { // TODO: We can't reopen Hibernate providers here if // they run on an in-memory database. // db4o should be reopened, otherwise Transparent Activation // is not tested. Reopen(); } ReplicateAll(A().Provider(), B().Provider()); Runtime.Gc(); // Improve chances TA is really required IObjectSet items = B().Provider().GetStoredObjects(typeof(ActivatableItem)); Assert.IsTrue(items.HasNext()); ActivatableItem replicatedItem = (ActivatableItem)items.Next(); Assert.AreEqual(item.Name(), replicatedItem.Name()); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/IDrsProviderFixture.cs000644 001750 001750 00000001633 11520622640 033407 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Inside; namespace Db4objects.Drs.Tests { public interface IDrsProviderFixture { ITestableReplicationProviderInside Provider(); void Open(); void Close(); void Clean(); void Destroy(); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/UntypedFieldTestCase.cs000644 001750 001750 00000010035 11520622640 033510 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class UntypedFieldTestCase : DrsTestCase { public virtual void TestUntypedString() { AssertUntypedReplication("42"); } public virtual void TestUntypedStringArray() { AssertUntypedReplication(new object[] { "42" }); } public virtual void TestUntypedStringJaggedArray() { AssertJaggedArray("42"); } public virtual void TestUntypedReferenceTypeJaggedArray() { AssertJaggedArray(new UntypedFieldData(42)); } public virtual void TestUntypedDate() { AssertUntypedReplication(new DateTime(100, 2, 2)); } public virtual void TestUntypedDateArray() { AssertUntypedReplication(new object[] { new DateTime(100, 2, 2) }); } public virtual void TestUntypedMixedArray() { AssertUntypedReplication(new object[] { "42", new UntypedFieldData(42) }); Assert.AreEqual(42, ((UntypedFieldData)SingleReplicatedInstance(typeof(UntypedFieldData ))).GetId()); } public virtual void TestArrayAsCloneable() { object[] array = new object[] { "42", new UntypedFieldData(42) }; ItemWithCloneable replicated = (ItemWithCloneable)Replicate(new ItemWithCloneable (array)); AssertEquals(array, replicated.value); } private void AssertUntypedReplication(object data) { AssertEquals(data, ReplicateItem(data).GetUntyped()); } private void AssertJaggedArray(object data) { object[] expected = new object[] { new object[] { data } }; object[] actual = (object[])ReplicateItem(expected).GetUntyped(); Assert.AreEqual(expected.Length, actual.Length); object[] nested = (object[])actual[0]; object actualValue = nested[0]; Assert.AreEqual(data, actualValue); AssertNotSame(data, actualValue); } private void AssertNotSame(object expectedReference, object actual) { if (!IsPrimitive(expectedReference.GetType())) { Assert.AreNotSame(expectedReference, actual); } } private bool IsPrimitive(Type klass) { if (klass.IsPrimitive) { return true; } if (klass == typeof(string)) { return true; } if (klass == typeof(DateTime)) { return true; } return false; } private void AssertEquals(object expected, object actual) { if (expected is object[]) { AssertEquals((object[])expected, (object[])actual); } else { Assert.AreEqual(expected, actual); AssertNotSame(expected, actual); } } private void AssertEquals(object[] expectedArray, object[] actualArray) { ArrayAssert.AreEqual(expectedArray, actualArray); for (int i = 0; i < expectedArray.Length; ++i) { AssertNotSame(expectedArray[i], actualArray[i]); } } private UntypedFieldItem ReplicateItem(object data) { return (UntypedFieldItem)Replicate(new UntypedFieldItem(data)); } private object Replicate(object item) { A().Provider().StoreNew(item); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider()); return SingleReplicatedInstance(item.GetType()); } private object SingleReplicatedInstance(Type klass) { IObjectSet found = B().Provider().GetStoredObjects(klass); Assert.AreEqual(1, found.Count); return found[0]; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4oDb4oDrsTestSuite.cs000644 001750 001750 00000002113 11520622636 033307 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class Db4oDb4oDrsTestSuite : ITestSuiteBuilder, IDb4oTestCase { public virtual IEnumerator GetEnumerator() { return new DrsTestSuiteBuilder(new Db4oDrsFixture("db4o-a"), new Db4oDrsFixture("db4o-b" ), typeof(Db4oDrsTestSuite)).GetEnumerator(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/TheSimplestTestSuite.cs000644 001750 001750 00000007214 11520622640 033600 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class TheSimplestTestSuite : FixtureBasedTestSuite { public class TheSimplest : DrsTestCase { public virtual void Test() { StoreInA(); Replicate(); ModifyInB(); Replicate2(); ModifyInA(); Replicate3(); } private void Replicate3() { ReplicateClass(A().Provider(), B().Provider(), typeof(SPCChild)); EnsureNames(A(), "c3"); EnsureNames(B(), "c3"); } private void ModifyInA() { SPCChild child = GetTheObject(A()); child.SetName("c3"); A().Provider().Update(child); A().Provider().Commit(); EnsureNames(A(), "c3"); } private void Replicate2() { ReplicateAll(B().Provider(), A().Provider()); EnsureNames(A(), "c2"); EnsureNames(B(), "c2"); } private void StoreInA() { SPCChild child = new SPCChild("c1"); A().Provider().StoreNew(child); A().Provider().Commit(); EnsureNames(A(), "c1"); } private void Replicate() { ReplicateAll(A().Provider(), B().Provider()); EnsureNames(A(), "c1"); EnsureNames(B(), "c1"); } private void ModifyInB() { SPCChild child = GetTheObject(B()); child.SetName("c2"); B().Provider().Update(child); B().Provider().Commit(); EnsureNames(B(), "c2"); } private void EnsureNames(IDrsProviderFixture fixture, string childName) { EnsureOneInstance(fixture, typeof(SPCChild)); SPCChild child = GetTheObject(fixture); Assert.AreEqual(childName, child.GetName()); } private SPCChild GetTheObject(IDrsProviderFixture fixture) { return (SPCChild)GetOneInstance(fixture, typeof(SPCChild)); } protected override void ReplicateClass(ITestableReplicationProviderInside providerA , ITestableReplicationProviderInside providerB, Type clazz) { //System.out.println("ReplicationTestcase.replicateClass"); IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures .reflector); IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator (); while (allObjects.MoveNext()) { object obj = allObjects.Current; //System.out.println("obj = " + obj); replication.Replicate(obj); } replication.Commit(); } } private static readonly FixtureVariable ConstructorConfigFixture = new FixtureVariable ("config"); public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SimpleFixtureProvider(TheSimplestTestSuite.ConstructorConfigFixture , new object[] { false, true }) }; } public override Type[] TestUnits() { return new Type[] { typeof(TheSimplestTestSuite.TheSimplest) }; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/PerformanceTestCase.cs000644 001750 001750 00000013065 11520622640 033363 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Db4o; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class PerformanceTestCase : DrsTestCase { private static int ListHolderCount = 10; private static int ObjectCount = 100; private static int TotalObjectCount = ListHolderCount + (ListHolderCount * ObjectCount * 2); public virtual void Test() { Sharpen.Runtime.Out.WriteLine("**** Simple Replication Performance Test ****"); long duration = StopWatch.Time(new _IBlock4_24(this)); Sharpen.Runtime.Out.WriteLine("**** Total time taken " + duration + "ms ****"); } private sealed class _IBlock4_24 : IBlock4 { public _IBlock4_24(PerformanceTestCase _enclosing) { this._enclosing = _enclosing; } public void Run() { Sharpen.Runtime.Out.WriteLine("Storing in " + this._enclosing.A().Provider().GetName ()); this._enclosing.StoreInA(); Sharpen.Runtime.Out.WriteLine("Replicating " + this._enclosing.A().Provider().GetName () + " to " + this._enclosing.B().Provider().GetName()); this._enclosing.Replicate(this._enclosing.A().Provider(), this._enclosing.B().Provider ()); Sharpen.Runtime.Out.WriteLine("Modifying in " + this._enclosing.B().Provider().GetName ()); this._enclosing.ModifyInB(); Sharpen.Runtime.Out.WriteLine("Replicating " + this._enclosing.B().Provider().GetName () + " to " + this._enclosing.A().Provider().GetName()); this._enclosing.Replicate(this._enclosing.B().Provider(), this._enclosing.A().Provider ()); } private readonly PerformanceTestCase _enclosing; } private void StoreInA() { long duration = StopWatch.Time(new _IBlock4_40(this)); Sharpen.Runtime.Out.WriteLine("Time to store " + TotalObjectCount + " objects: " + duration + "ms"); } private sealed class _IBlock4_40 : IBlock4 { public _IBlock4_40(PerformanceTestCase _enclosing) { this._enclosing = _enclosing; } public void Run() { for (int i = 0; i < PerformanceTestCase.ListHolderCount; i++) { SimpleListHolder listHolder = new SimpleListHolder("CreatedHolder"); for (int j = 0; j < PerformanceTestCase.ObjectCount; j++) { SimpleItem child = new SimpleItem("CreatedChild"); SimpleItem parent = new SimpleItem(listHolder, child, "CreatedParent"); this._enclosing.A().Provider().StoreNew(parent); listHolder.Add(parent); } this._enclosing.A().Provider().StoreNew(listHolder); this._enclosing.A().Provider().Commit(); } this._enclosing.A().Provider().Commit(); } private readonly PerformanceTestCase _enclosing; } private void Replicate(ITestableReplicationProviderInside from, ITestableReplicationProviderInside to) { long duration = StopWatch.Time(new _IBlock4_60(this, from, to)); Sharpen.Runtime.Out.WriteLine("Time to replicate " + TotalObjectCount + " objects: " + duration + "ms"); } private sealed class _IBlock4_60 : IBlock4 { public _IBlock4_60(PerformanceTestCase _enclosing, ITestableReplicationProviderInside from, ITestableReplicationProviderInside to) { this._enclosing = _enclosing; this.from = from; this.to = to; } public void Run() { this._enclosing.ReplicateAll(from, to); } private readonly PerformanceTestCase _enclosing; private readonly ITestableReplicationProviderInside from; private readonly ITestableReplicationProviderInside to; } private void ModifyInB() { long duration = StopWatch.Time(new _IBlock4_69(this)); Sharpen.Runtime.Out.WriteLine("Time to update " + TotalObjectCount + " objects: " + duration + "ms"); } private sealed class _IBlock4_69 : IBlock4 { public _IBlock4_69(PerformanceTestCase _enclosing) { this._enclosing = _enclosing; } public void Run() { IObjectSet storedObjects = this._enclosing.B().Provider().GetStoredObjects(typeof( SimpleListHolder)); while (storedObjects.HasNext()) { SimpleListHolder listHolder = (SimpleListHolder)storedObjects.Next(); listHolder.SetName("modifiedHolder"); IEnumerator i = listHolder.GetList().GetEnumerator(); while (i.MoveNext()) { SimpleItem parent = (SimpleItem)i.Current; parent.SetValue("ModifiedParent"); this._enclosing.B().Provider().Update(parent); SimpleItem child = parent.GetChild(); child.SetValue("ModifiedChild"); this._enclosing.B().Provider().Update(child); this._enclosing.B().Provider().Commit(); } this._enclosing.B().Provider().Update(listHolder); this._enclosing.B().Provider().Update(listHolder.GetList()); } } private readonly PerformanceTestCase _enclosing; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ArrayTestSuite.cs000644 001750 001750 00000005574 11520622636 032431 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Handlers.Array; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ArrayTestSuite : FixtureBasedTestSuite { public class TestUnit : DrsTestCase { public virtual void Test() { ItemWithUntypedField item = new ItemWithUntypedField(Subject()); StoreToProviderA(item); ReplicatedAllToB(); ItemWithUntypedField replicated = ReplicatedItem(); Assert.IsNotNull(replicated.Array()); Iterator4Assert.AreEqual(ArrayIterator(item.Array()), ArrayIterator(replicated.Array ())); } private IEnumerator ArrayIterator(object array) { return ArrayHandler.Iterator(ReflectClass(array), array); } private IReflectClass ReflectClass(object array) { return GenericReflector().ForObject(array); } private Db4objects.Db4o.Reflect.Generic.GenericReflector GenericReflector() { return new Db4objects.Db4o.Reflect.Generic.GenericReflector(null, Platform4.ReflectorForType (GetType())); } private void ReplicatedAllToB() { ReplicateAll(A().Provider(), B().Provider()); } private void StoreToProviderA(ItemWithUntypedField item) { A().Provider().StoreNew(item); A().Provider().Commit(); } private ItemWithUntypedField ReplicatedItem() { IEnumerator iterator = B().Provider().GetStoredObjects(typeof(ItemWithUntypedField )).GetEnumerator(); if (iterator.MoveNext()) { return (ItemWithUntypedField)iterator.Current; } return null; } private object Subject() { return SubjectFixtureProvider.Value(); } } public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SubjectFixtureProvider(new object[] { new object [] { }, new string[] { "foo", "bar" }, new int[] { 42, -1, 0 }, new int[][] { } , new DateTime[] { new DateTime() } }) }; } public override Type[] TestUnits() { return new Type[] { typeof(ArrayTestSuite.TestUnit) }; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Staging/000755 001750 001750 00000000000 11520622064 030526 5ustar00directhexdirecthex000000 000000 src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Staging/MapElementCustomHashCodeTestCase.cs000644 001750 001750 00000002743 11520622640 037261 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Staging; namespace Db4objects.Drs.Tests.Staging { public class MapElementCustomHashCodeTestCase : EqualsHashCodeOverriddenTestCaseBase { public class Holder { internal IDictionary _map = new Hashtable(); public Holder(EqualsHashCodeOverriddenTestCaseBase.Item itemA, EqualsHashCodeOverriddenTestCaseBase.Item itemB) { // DRS-118 // NOTE: This test does not necessarily reproduce the symptom. _map[itemA] = itemA; _map[itemB] = itemB; } } public virtual void TestReplicatesMap() { AssertReplicates(new MapElementCustomHashCodeTestCase.Holder(new EqualsHashCodeOverriddenTestCaseBase.Item ("item"), new EqualsHashCodeOverriddenTestCaseBase.Item("item"))); } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4oClientServerDrsFixture.cs000644 001750 001750 00000004013 11520622636 034543 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; using Db4objects.Db4o.CS; using Db4objects.Db4o.CS.Internal.Config; using Db4objects.Db4o.Config; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Db4o; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class Db4oClientServerDrsFixture : Db4oDrsFixture { private static readonly string Host = "localhost"; private static readonly string Username = "db4o"; private static readonly string Password = Username; private IObjectServer _server; private int _port; public Db4oClientServerDrsFixture(string name, int port) : base(name) { _port = port; } public override void Close() { base.Close(); _server.Close(); } public override void Open() { Config().MessageLevel(-1); _server = Db4oClientServer.OpenServer(Db4oClientServerLegacyConfigurationBridge.AsServerConfiguration (CloneConfiguration()), testFile.GetPath(), _port); _server.GrantAccess(Username, Password); _db = Db4oClientServer.OpenClient(Db4oClientServerLegacyConfigurationBridge.AsClientConfiguration (CloneConfiguration()), Host, _port, Username, Password).Ext(); _provider = Db4oProviderFactory.NewInstance(_db, _name); } private IConfiguration CloneConfiguration() { return (IConfiguration)((IDeepClone)Config()).DeepClone(Config()); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4o/000755 001750 001750 00000000000 11520622070 027717 5ustar00directhexdirecthex000000 000000 src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4o/PartialCollectionReplicationTestCase.cs000644 001750 001750 00000017414 11520622636 037444 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using Db4oUnit; using Db4objects.Db4o.Events; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Db4o; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Db4o; namespace Db4objects.Drs.Tests.Db4o { public class PartialCollectionReplicationTestCase : DrsTestCase { public class Data { private IList _children; private string _id; public Data(string id) { _id = id; _children = new ArrayList(); } public virtual object Id() { return _id; } public virtual void Id(string id) { _id = id; } public virtual void Add(PartialCollectionReplicationTestCase.Data data) { _children.Add(data); } public override string ToString() { return "Data(" + _id + ", " + _children + ")"; } } public virtual void TestNoReplicationForUntouchedElements() { PartialCollectionReplicationTestCase.Data root = new PartialCollectionReplicationTestCase.Data ("root"); PartialCollectionReplicationTestCase.Data c1 = new PartialCollectionReplicationTestCase.Data ("c1"); PartialCollectionReplicationTestCase.Data c2 = new PartialCollectionReplicationTestCase.Data ("c2"); root.Add(c1); root.Add(c2); Store(root, 1); IList created = ReplicateAllCapturingCreatedObjects (); AssertData(created, "root", "c1", "c2"); PartialCollectionReplicationTestCase.Data c3 = new PartialCollectionReplicationTestCase.Data ("c3"); root.Add(c3); Store(root, 2); c2.Id("c2*"); c2.Add(new PartialCollectionReplicationTestCase.Data("c4")); IList updated = ReplicateAllCapturingUpdatedObjects (); } // The following fails after cleaning references has been removed from #replicate(obj) // assertData(updated, "c3", "root"); private void AssertData(IEnumerable data , params string[] expectedIds) { Iterator4Assert.SameContent(expectedIds, Ids(data)); } private IEnumerator Ids(IEnumerable data ) { Collection4 ids = new Collection4(); foreach (PartialCollectionReplicationTestCase.Data d in data) { ids.Add(d.Id()); } return ids.GetEnumerator(); } private IList ReplicateAllCapturingUpdatedObjects () { IList changed = new List(); ListenToUpdated(changed); ListenToCreated(changed); ReplicateAll(); return changed; } private IList ReplicateAllCapturingCreatedObjects () { IList created = new List(); ListenToCreated(created); ReplicateAll(); return created; } private void ListenToUpdated(IList updated ) { EventRegistryFor(B()).Updated += new System.EventHandler (new _IEventListener4_97(this, updated).OnEvent); } private sealed class _IEventListener4_97 { public _IEventListener4_97(PartialCollectionReplicationTestCase _enclosing, IList updated) { this._enclosing = _enclosing; this.updated = updated; } public void OnEvent(object sender, Db4objects.Db4o.Events.ObjectInfoEventArgs args ) { object o = ((ObjectEventArgs)args).Object; if (o is PartialCollectionReplicationTestCase.Data) { updated.Add((PartialCollectionReplicationTestCase.Data)o); } this._enclosing.Ods(o); } private readonly PartialCollectionReplicationTestCase _enclosing; private readonly IList updated; } private void ReplicateAll() { Ods("BEGIN REPLICATION"); ReplicateAll(A().Provider(), B().Provider()); Ods("END REPLICATION"); } private void ListenToCreated(IList created ) { EventRegistryFor(B()).Created += new System.EventHandler (new _IEventListener4_115(this, created).OnEvent); } private sealed class _IEventListener4_115 { public _IEventListener4_115(PartialCollectionReplicationTestCase _enclosing, IList created) { this._enclosing = _enclosing; this.created = created; } public void OnEvent(object sender, Db4objects.Db4o.Events.ObjectInfoEventArgs args ) { object o = ((ObjectEventArgs)args).Object; if (o is PartialCollectionReplicationTestCase.Data) { created.Add((PartialCollectionReplicationTestCase.Data)o); } this._enclosing.Ods(o); } private readonly PartialCollectionReplicationTestCase _enclosing; private readonly IList created; } private IEventRegistry EventRegistryFor(IDrsProviderFixture fixture) { return EventRegistryFactory.ForObjectContainer(ContainerFor(fixture)); } public virtual void TestCollectionUpdateDoesNotTouchExistingElements() { PartialCollectionReplicationTestCase.Data root = new PartialCollectionReplicationTestCase.Data ("root"); PartialCollectionReplicationTestCase.Data c1 = new PartialCollectionReplicationTestCase.Data ("c1"); PartialCollectionReplicationTestCase.Data c2 = new PartialCollectionReplicationTestCase.Data ("c2"); root.Add(c1); root.Add(c2); Store(root, 1); long c1Version = VersionFor(c1); long c2Version = VersionFor(c2); PartialCollectionReplicationTestCase.Data c3 = new PartialCollectionReplicationTestCase.Data ("c3"); root.Add(c3); Store(root, 2); Assert.IsGreater(0, VersionFor(c3)); Assert.AreEqual(c1Version, VersionFor(c1)); Assert.AreEqual(c2Version, VersionFor(c2)); } private void Store(PartialCollectionReplicationTestCase.Data root, int depth) { IExtObjectContainer container = ContainerFor(A()); container.Ext().Store(root, depth); container.Commit(); } private IExtObjectContainer ContainerFor(IDrsProviderFixture fixture) { return ((IDb4oReplicationProvider)fixture.Provider()).GetObjectContainer(); } private long VersionFor(PartialCollectionReplicationTestCase.Data c1) { return ObjectInfoFor(c1).GetCommitTimestamp(); } private IObjectInfo ObjectInfoFor(PartialCollectionReplicationTestCase.Data c1) { return ContainerFor(A()).Ext().GetObjectInfo(c1); } private void Ods(object o) { } // System.out.println(o); public static void Main(string[] args) { new ConsoleTestRunner(new DrsTestSuiteBuilder(new Db4oDrsFixture("db4o-a"), new Db4oDrsFixture ("db4o-b"), typeof(PartialCollectionReplicationTestCase))).Run(); } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ReplicationAfterDeletionTest.cs000644 001750 001750 00000002452 11520622640 035164 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ReplicationAfterDeletionTest : DrsTestCase { public virtual void Test() { Replicate(); Clean(); Replicate(); Clean(); } protected override void Clean() { Delete(new Type[] { typeof(SPCChild), typeof(SPCParent) }); } private void Replicate() { SPCChild child = new SPCChild("c1"); SPCParent parent = new SPCParent(child, "p1"); A().Provider().StoreNew(parent); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider()); } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/CollectionHandlerImplTest.cs000644 001750 001750 00000004105 11520622636 034462 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class CollectionHandlerImplTest : DrsTestCase { private CollectionHandlerImpl _collectionHandler; public virtual void TestVector() { ArrayList vector = new ArrayList(); Assert.IsTrue(CollectionHandler().CanHandle(vector)); Assert.IsTrue(CollectionHandler().CanHandleClass(ReplicationReflector().ForObject (vector))); Assert.IsTrue(CollectionHandler().CanHandleClass(typeof(ArrayList))); } public virtual void TestMap() { IDictionary map = new Hashtable(); Assert.IsTrue(CollectionHandler().CanHandle(map)); Assert.IsTrue(CollectionHandler().CanHandleClass(ReplicationReflector().ForObject (map))); Assert.IsTrue(CollectionHandler().CanHandleClass(typeof(IDictionary))); } public virtual void TestString() { string str = "abc"; Assert.IsTrue(!CollectionHandler().CanHandle(str)); Assert.IsTrue(!CollectionHandler().CanHandleClass(ReplicationReflector().ForObject (str))); Assert.IsTrue(!CollectionHandler().CanHandleClass(typeof(string))); } private Db4objects.Drs.Inside.ICollectionHandler CollectionHandler() { if (_collectionHandler == null) { _collectionHandler = new CollectionHandlerImpl(ReplicationReflector()); } return _collectionHandler; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/SimpleArrayTest.cs000644 001750 001750 00000010307 11520622640 032552 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class SimpleArrayTest : DrsTestCase { public virtual void Test() { StoreListToProviderA(); ReplicateAllToProviderBFirstTime(); ModifyInProviderB(); ReplicateAllStep2(); AddElementInProviderA(); ReplicateHolderStep3(); } protected override void Clean() { Delete(new Type[] { typeof(SimpleArrayHolder), typeof(SimpleArrayContent) }); } private void StoreListToProviderA() { SimpleArrayHolder sah = new SimpleArrayHolder("h1"); SimpleArrayContent sac1 = new SimpleArrayContent("c1"); SimpleArrayContent sac2 = new SimpleArrayContent("c2"); sah.Add(sac1); sah.Add(sac2); A().Provider().StoreNew(sah); A().Provider().Commit(); EnsureContent(A(), new string[] { "h1" }, new string[] { "c1", "c2" }); } private void ReplicateAllToProviderBFirstTime() { ReplicateAll(A().Provider(), B().Provider()); EnsureContent(A(), new string[] { "h1" }, new string[] { "c1", "c2" }); EnsureContent(B(), new string[] { "h1" }, new string[] { "c1", "c2" }); } private void ModifyInProviderB() { SimpleArrayHolder sah = (SimpleArrayHolder)GetOneInstance(B(), typeof(SimpleArrayHolder )); sah.SetName("h2"); SimpleArrayContent sac1 = sah.GetArr()[0]; SimpleArrayContent sac2 = sah.GetArr()[1]; sac1.SetName("co1"); sac2.SetName("co2"); B().Provider().Update(sac1); B().Provider().Update(sac2); B().Provider().Update(sah); B().Provider().Commit(); EnsureContent(B(), new string[] { "h2" }, new string[] { "co1", "co2" }); } private void ReplicateAllStep2() { ReplicateAll(B().Provider(), A().Provider()); EnsureContent(B(), new string[] { "h2" }, new string[] { "co1", "co2" }); EnsureContent(A(), new string[] { "h2" }, new string[] { "co1", "co2" }); } private void AddElementInProviderA() { SimpleArrayHolder sah = (SimpleArrayHolder)GetOneInstance(A(), typeof(SimpleArrayHolder )); sah.SetName("h3"); SimpleArrayContent lc3 = new SimpleArrayContent("co3"); A().Provider().StoreNew(lc3); sah.Add(lc3); A().Provider().Update(sah); A().Provider().Commit(); EnsureContent(A(), new string[] { "h3" }, new string[] { "co1", "co2", "co3" }); } private void ReplicateHolderStep3() { ReplicateClass(A().Provider(), B().Provider(), typeof(SimpleArrayHolder)); EnsureContent(A(), new string[] { "h3" }, new string[] { "co1", "co2", "co3" }); EnsureContent(B(), new string[] { "h3" }, new string[] { "co1", "co2", "co3" }); } private void EnsureContent(IDrsProviderFixture fixture, string[] holderNames, string [] contentNames) { int holderCount = holderNames.Length; int contentCount = contentNames.Length; EnsureInstanceCount(fixture, typeof(SimpleArrayHolder), holderCount); EnsureInstanceCount(fixture, typeof(SimpleArrayContent), contentCount); int i = 0; IObjectSet objectSet = fixture.Provider().GetStoredObjects(typeof(SimpleArrayHolder )); IEnumerator iterator = objectSet.GetEnumerator(); while (iterator.MoveNext()) { SimpleArrayHolder lh = (SimpleArrayHolder)iterator.Current; Assert.AreEqual(holderNames[i], lh.GetName()); SimpleArrayContent[] sacs = lh.GetArr(); for (int j = 0; j < contentNames.Length; j++) { Assert.AreEqual(contentNames[j], sacs[j].GetName()); } } } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/SameHashCodeTestCase.cs000644 001750 001750 00000002575 11520622640 033412 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class SameHashCodeTestCase : EqualsHashCodeOverriddenTestCaseBase { public class Holder { internal EqualsHashCodeOverriddenTestCaseBase.Item _itemA; internal EqualsHashCodeOverriddenTestCaseBase.Item _itemB; public Holder(EqualsHashCodeOverriddenTestCaseBase.Item itemA, EqualsHashCodeOverriddenTestCaseBase.Item itemB) { _itemA = itemA; _itemB = itemB; } } public virtual void TestReplicatesSimpleHolder() { AssertReplicates(new SameHashCodeTestCase.Holder(new EqualsHashCodeOverriddenTestCaseBase.Item ("item"), new EqualsHashCodeOverriddenTestCaseBase.Item("item"))); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/UuidConversionTestCase.cs000644 001750 001750 00000003447 11520622640 034101 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class UuidConversionTestCase : DrsTestCase { public virtual void Test() { SPCChild child = StoreInA(); Replicate(); IReplicationReference @ref = A().Provider().ProduceReference(child); B().Provider().ClearAllReferences(); IDrsUUID expectedUuid = @ref.Uuid(); IReplicationReference referenceByUUID = B().Provider().ProduceReferenceByUUID(expectedUuid , null); Assert.IsNotNull(referenceByUUID); IDrsUUID actualUuid = referenceByUUID.Uuid(); Assert.AreEqual(expectedUuid.GetLongPart(), actualUuid.GetLongPart()); } private SPCChild StoreInA() { string name = "c1"; SPCChild child = CreateChildObject(name); A().Provider().StoreNew(child); A().Provider().Commit(); return child; } private void Replicate() { ReplicateAll(A().Provider(), B().Provider()); } protected virtual SPCChild CreateChildObject(string name) { return new SPCChild(name); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/CollectionAssert.cs000644 001750 001750 00000002224 11520622636 032743 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class CollectionAssert { public static void AreEqual(IEnumerable expected, IEnumerable actual) { Iterator4Assert.AreEqual(CollectionAssert.Adapt(expected.GetEnumerator()), CollectionAssert .Adapt(actual.GetEnumerator())); } internal static IEnumerator Adapt(IEnumerator iterator) { return ReplicationTestPlatform.Adapt(iterator); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/VersantDrsTestSuite.cs000644 001750 001750 00000002047 11520622640 033431 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class VersantDrsTestSuite : DrsTestSuite { protected override Type[] TestCases() { return Concat(base.TestCases(), SpecificTestcases()); } private Type[] SpecificTestcases() { return new Type[] { typeof(ArrayTestSuite), typeof(CustomArrayListTestCase) }; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/TheSimplest.cs000644 001750 001750 00000006143 11520622640 031726 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class TheSimplest : DrsTestCase { public virtual void Test() { StoreInA(); Replicate(); ModifyInB(); Replicate2(); ModifyInA(); Replicate3(); } private void StoreInA() { string name = "c1"; SPCChild child = CreateChildObject(name); A().Provider().StoreNew(child); A().Provider().Commit(); EnsureNames(A(), "c1"); } private void Replicate() { ReplicateAll(A().Provider(), B().Provider()); EnsureNames(A(), "c1"); EnsureNames(B(), "c1"); } private void ModifyInB() { SPCChild child = GetTheObject(B()); child.SetName("c2"); B().Provider().Update(child); B().Provider().Commit(); EnsureNames(B(), "c2"); } private void Replicate2() { ReplicateAll(B().Provider(), A().Provider()); EnsureNames(A(), "c2"); EnsureNames(B(), "c2"); } private void ModifyInA() { SPCChild child = GetTheObject(A()); child.SetName("c3"); A().Provider().Update(child); A().Provider().Commit(); EnsureNames(A(), "c3"); } private void Replicate3() { ReplicateClass(A().Provider(), B().Provider(), typeof(SPCChild)); EnsureNames(A(), "c3"); EnsureNames(B(), "c3"); } protected virtual SPCChild CreateChildObject(string name) { return new SPCChild(name); } private void EnsureNames(IDrsProviderFixture fixture, string childName) { EnsureOneInstance(fixture, typeof(SPCChild)); SPCChild child = GetTheObject(fixture); Assert.AreEqual(childName, child.GetName()); } private SPCChild GetTheObject(IDrsProviderFixture fixture) { return (SPCChild)GetOneInstance(fixture, typeof(SPCChild)); } protected override void ReplicateClass(ITestableReplicationProviderInside providerA , ITestableReplicationProviderInside providerB, Type clazz) { IReplicationSession replication = Replication.Begin(providerA, providerB, _fixtures .reflector); IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator (); while (allObjects.MoveNext()) { object obj = allObjects.Current; //System.out.println("obj = " + obj); replication.Replicate(obj); } replication.Commit(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ByteArrayTest.cs000644 001750 001750 00000006141 11520622636 032232 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { /// /// Design of this case is copied from /// com.db4o.db4ounit.common.types.arrays.ByteArrayTestCase. /// /// /// Design of this case is copied from /// com.db4o.db4ounit.common.types.arrays.ByteArrayTestCase. /// public class ByteArrayTest : DrsTestCase { internal const int ArrayLength = 5; internal static byte[] initial = CreateByteArray(); internal static byte[] modInB = new byte[] { 2, 3, 5, 68, 69 }; internal static byte[] modInA = new byte[] { 15, 36, 55, 8, 9, 28, 65 }; public virtual void Test() { StoreInA(); Replicate(); ModifyInB(); Replicate2(); ModifyInA(); Replicate3(); } private void StoreInA() { IIByteArrayHolder byteArrayHolder = new ByteArrayHolder(CreateByteArray()); A().Provider().StoreNew(byteArrayHolder); A().Provider().Commit(); EnsureNames(A(), initial); } private void Replicate() { ReplicateAll(A().Provider(), B().Provider()); EnsureNames(A(), initial); EnsureNames(B(), initial); } private void ModifyInB() { IIByteArrayHolder c = GetTheObject(B()); c.SetBytes(modInB); B().Provider().Update(c); B().Provider().Commit(); EnsureNames(B(), modInB); } private void Replicate2() { ReplicateAll(B().Provider(), A().Provider()); EnsureNames(A(), modInB); EnsureNames(B(), modInB); } private void ModifyInA() { IIByteArrayHolder c = GetTheObject(A()); c.SetBytes(modInA); A().Provider().Update(c); A().Provider().Commit(); EnsureNames(A(), modInA); } private void Replicate3() { ReplicateAll(A().Provider(), B().Provider()); EnsureNames(A(), modInA); EnsureNames(B(), modInA); } private void EnsureNames(IDrsProviderFixture fixture, byte[] bs) { EnsureOneInstance(fixture, typeof(ByteArrayHolder)); IIByteArrayHolder c = GetTheObject(fixture); ArrayAssert.AreEqual(c.GetBytes(), bs); } private IIByteArrayHolder GetTheObject(IDrsProviderFixture fixture) { return (ByteArrayHolder)GetOneInstance(fixture, typeof(ByteArrayHolder)); } internal static byte[] CreateByteArray() { byte[] bytes = new byte[ArrayLength]; for (byte i = 0; i < bytes.Length; ++i) { bytes[i] = i; } return bytes; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/000755 001750 001750 00000000000 11520622070 030000 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ByteArrayHolder.cs000644 001750 001750 00000002121 11520622636 033373 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class ByteArrayHolder : IIByteArrayHolder { private byte[] _bytes; public ByteArrayHolder() { } public ByteArrayHolder(byte[] bytes) { this._bytes = bytes; } public virtual byte[] GetBytes() { return _bytes; } public virtual void SetBytes(byte[] bytes) { _bytes = bytes; } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ItemWithUntypedField.cs000644 001750 001750 00000002040 11520622636 034323 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class ItemWithUntypedField { private object _array; public ItemWithUntypedField() { } public ItemWithUntypedField(object array) { Array(array); } public virtual void Array(object array) { this._array = array; } public virtual object Array() { return _array; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ActivatableItem.cs000644 001750 001750 00000003123 11520622636 033374 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Activation; using Db4objects.Db4o.TA; namespace Db4objects.Drs.Tests.Data { /// public class ActivatableItem : IActivatable { private string name; [System.NonSerialized] private IActivator _activator; public ActivatableItem() { } public ActivatableItem(string name) { this.name = name; } public virtual void Activate(ActivationPurpose purpose) { if (_activator != null) { _activator.Activate(purpose); } } public virtual void Bind(IActivator activator) { _activator = activator; } public virtual object Name() { Activate(ActivationPurpose.Read); return name; } public virtual string GetName() { Activate(ActivationPurpose.Read); return name; } public virtual void SetName(string name) { Activate(ActivationPurpose.Write); this.name = name; } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SPCChildWithoutDefaultConstructor.cs000644 001750 001750 00000001612 11520622636 037010 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class SPCChildWithoutDefaultConstructor : SPCChild { public SPCChildWithoutDefaultConstructor(string name) : base(name) { } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/CollectionHolder.cs000644 001750 001750 00000003675 11520622636 033603 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Sharpen.Util; namespace Db4objects.Drs.Tests.Data { public class CollectionHolder { private string name; private IDictionary map; private IList list; private Sharpen.Util.ISet set; public CollectionHolder(string name, IDictionary theMap, Sharpen.Util.ISet theSet , IList theList) { this.name = name; map = theMap; set = theSet; list = theList; } public CollectionHolder() : this("HashMap", new Hashtable(), new HashSet(), new ArrayList ()) { } public CollectionHolder(string name) : this() { this.name = name; } public override string ToString() { return name + ", hashcode = " + GetHashCode(); } public virtual void Map(IDictionary map) { this.map = map; } public virtual IDictionary Map() { return map; } public virtual void List(IList list) { this.list = list; } public virtual IList List() { return list; } public virtual void Set(Sharpen.Util.ISet set) { this.set = set; } public virtual Sharpen.Util.ISet Set() { return set; } public virtual void Name(string name) { this.name = name; } public virtual string Name() { return name; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/R0.cs000644 001750 001750 00000002325 11520622636 030622 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class R0 { internal string name; internal R0 r0; internal R1 r1; public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public virtual R0 GetR0() { return r0; } public virtual void SetR0(R0 r0) { this.r0 = r0; } public virtual R1 GetR1() { return r1; } public virtual void SetR1(R1 r1) { this.r1 = r1; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ListContent.cs000644 001750 001750 00000002122 11520622636 032602 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class ListContent { private string name; public ListContent() { } public ListContent(string name) { this.name = name; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public override string ToString() { return "name = " + name; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/Car.cs000644 001750 001750 00000002304 11520622636 031043 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class Car { private string _model; private Pilot _pilot; public Car() { } public Car(string model) { _model = model; } public virtual string GetModel() { return _model; } public virtual void SetModel(string model) { _model = model; } public virtual Pilot GetPilot() { return _pilot; } public virtual void SetPilot(Pilot newPilot) { _pilot = newPilot; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/Pilot.cs000644 001750 001750 00000002174 11520622636 031432 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class Pilot { private string _name; private int _age; public Pilot() { } public Pilot(string name, int age) { this._name = name; this._age = age; } public virtual void SetName(string name) { this._name = name; } public virtual string Name() { return _name; } public override string ToString() { return "Pilot name:" + Name(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/MapContent.cs000644 001750 001750 00000003003 11520622636 032403 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class MapContent { private string name; public MapContent() { } public MapContent(string name) { this.name = name; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public override string ToString() { return "name = " + name; } public override bool Equals(object o) { if (this == o) { return true; } if (o == null || GetType() != o.GetType()) { return false; } Db4objects.Drs.Tests.Data.MapContent that = (Db4objects.Drs.Tests.Data.MapContent )o; if (!name.Equals(that.name)) { return false; } return true; } public override int GetHashCode() { return name.GetHashCode(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/UntypedFieldData.cs000644 001750 001750 00000002267 11520622636 033534 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public sealed class UntypedFieldData { private int id; public UntypedFieldData() { } public UntypedFieldData(int value) { SetId(value); } public override bool Equals(object obj) { Db4objects.Drs.Tests.Data.UntypedFieldData other = (Db4objects.Drs.Tests.Data.UntypedFieldData )obj; return GetId() == other.GetId(); } public void SetId(int id) { this.id = id; } public int GetId() { return id; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SimpleArrayHolder.cs000644 001750 001750 00000003130 11520622636 033722 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; using Sharpen; namespace Db4objects.Drs.Tests.Data { public class SimpleArrayHolder { private string name; private SimpleArrayContent[] arr; public SimpleArrayHolder() { } public SimpleArrayHolder(string name) { this.name = name; } public virtual SimpleArrayContent[] GetArr() { return arr; } public virtual void SetArr(SimpleArrayContent[] arr) { this.arr = arr; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public virtual void Add(SimpleArrayContent sac) { if (arr == null) { arr = new SimpleArrayContent[] { sac }; return; } SimpleArrayContent[] temp = arr; arr = new SimpleArrayContent[temp.Length + 1]; System.Array.Copy(temp, 0, arr, 0, temp.Length); arr[temp.Length] = sac; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SimpleItem.cs000644 001750 001750 00000005310 11520622636 032406 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class SimpleItem { private string value; private Db4objects.Drs.Tests.Data.SimpleItem child; private SimpleListHolder parent; public SimpleItem() { } public SimpleItem(SimpleListHolder parent_, Db4objects.Drs.Tests.Data.SimpleItem child_, string value_) { parent = parent_; value = value_; child = child_; } public SimpleItem(string value_) : this(null, null, value_) { } public SimpleItem(Db4objects.Drs.Tests.Data.SimpleItem child, string value_) : this (null, child, value_) { } public SimpleItem(SimpleListHolder parent_, string value_) : this(parent_, null, value_) { } public virtual string GetValue() { return value; } public virtual void SetValue(string value_) { value = value_; } public virtual Db4objects.Drs.Tests.Data.SimpleItem GetChild() { return GetChild(0); } public virtual Db4objects.Drs.Tests.Data.SimpleItem GetChild(int level) { Db4objects.Drs.Tests.Data.SimpleItem tbr = child; while (--level > 0 && tbr != null) { tbr = tbr.child; } return tbr; } public virtual void SetChild(Db4objects.Drs.Tests.Data.SimpleItem child_) { child = child_; } public virtual SimpleListHolder GetParent() { return parent; } public virtual void SetParent(SimpleListHolder parent_) { parent = parent_; } public override bool Equals(object obj) { if (obj.GetType() != typeof(Db4objects.Drs.Tests.Data.SimpleItem)) { return false; } Db4objects.Drs.Tests.Data.SimpleItem rhs = (Db4objects.Drs.Tests.Data.SimpleItem) obj; return rhs.GetValue().Equals(GetValue()); } public override string ToString() { string childString; if (child != null) { childString = child != this ? child.ToString() : "this"; } else { childString = "null"; } return value + "[" + childString + "]"; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SPCChild.cs000644 001750 001750 00000002143 11520622636 031730 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class SPCChild { private string name; public SPCChild() { } public SPCChild(string name) { this.name = name; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public override string ToString() { return "SPCChild{" + "name='" + name + '\'' + '}'; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/MapHolder.cs000644 001750 001750 00000002643 11520622636 032217 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; namespace Db4objects.Drs.Tests.Data { public class MapHolder { private string name; private IDictionary map; public MapHolder() { } public MapHolder(string name) { this.name = name; this.map = new Hashtable(); } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public virtual IDictionary GetMap() { return map; } public virtual void SetMap(IDictionary map) { this.map = map; } public virtual void Put(object key, object value) { map[key] = value; } public override string ToString() { return "name = " + name + ", map = " + map; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/Value.cs000644 001750 001750 00000002100 11520622636 031404 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public struct Value { public int value; public Value(int value) { this.value = value; } public override bool Equals(object obj) { if (!(obj is Db4objects.Drs.Tests.Data.Value)) { return false; } Db4objects.Drs.Tests.Data.Value other = (Db4objects.Drs.Tests.Data.Value)obj; return other.value == value; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/NamedList.cs000644 001750 001750 00000002033 11520622636 032215 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests.Data { public class NamedList : DelegatingList { private string _name; public NamedList() : this(null) { } public NamedList(string name) : base(new ArrayList()) { _name = name; } public virtual string Name() { return _name; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/NewPilot.cs000644 001750 001750 00000002737 11520622636 032111 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class NewPilot { internal string name; internal int points; internal int[] arr; public NewPilot() { } public NewPilot(string name, int points, int[] arr) { this.name = name; this.points = points; this.arr = arr; } public virtual int[] GetArr() { return arr; } public virtual void SetArr(int[] arr) { this.arr = arr; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public virtual int GetPoints() { return points; } public virtual void SetPoints(int points) { this.points = points; } public override string ToString() { return name + "/" + points; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SPCParent.cs000644 001750 001750 00000002700 11520622636 032135 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class SPCParent { private SPCChild child; private string name; public SPCParent() { } public SPCParent(string name) { this.name = name; } public SPCParent(SPCChild child, string name) { this.child = child; this.name = name; } public virtual SPCChild GetChild() { return child; } public virtual void SetChild(SPCChild child) { this.child = child; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public override string ToString() { return "SPCParent{" + "child=" + child + ", name='" + name + '\'' + '}'; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/IIByteArrayHolder.cs000644 001750 001750 00000001467 11520622636 033631 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public interface IIByteArrayHolder { byte[] GetBytes(); void SetBytes(byte[] bytes); } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/Container.cs000644 001750 001750 00000002052 11520622636 032260 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class Container { private Value value; public Container() { } public Container(Value value) { this.SetValue(value); } public virtual void SetValue(Value value) { this.value = value; } public virtual Value GetValue() { return value; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SimpleListHolder.cs000644 001750 001750 00000002517 11520622636 033567 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class SimpleListHolder { private string _name; private IList list = new ArrayList(); public SimpleListHolder() { } public SimpleListHolder(string name) { _name = name; } public virtual IList GetList() { return list; } public virtual void SetList(IList list) { this.list = list; } public virtual void Add(SimpleItem item) { list.Add(item); } public virtual void SetName(string name) { _name = name; } public virtual string GetName() { return _name; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/R4.cs000644 001750 001750 00000001705 11520622636 030627 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class R4 : R3 { internal R0 circle4; public virtual R0 GetCircle4() { return circle4; } public virtual void SetCircle4(R0 circle4) { this.circle4 = circle4; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ItemWithCloneable.cs000644 001750 001750 00000001636 11520622636 033704 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4objects.Drs.Tests.Data { public sealed class ItemWithCloneable { public ICloneable value; public ItemWithCloneable() { } public ItemWithCloneable(ICloneable c) { value = c; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/UntypedFieldItem.cs000644 001750 001750 00000002041 11520622636 033547 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public sealed class UntypedFieldItem { private object untyped; public UntypedFieldItem() { } public UntypedFieldItem(object value) { SetUntyped(value); } public void SetUntyped(object untyped) { this.untyped = untyped; } public object GetUntyped() { return untyped; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/Replicated.cs000644 001750 001750 00000003476 11520622636 032425 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Sharpen; namespace Db4objects.Drs.Tests.Data { public class Replicated { private string name; private Db4objects.Drs.Tests.Data.Replicated link; public Replicated() { } public Replicated(string name) { this.SetName(name); } public override string ToString() { return GetName() + ", hashcode = " + GetHashCode() + ", identity = " + Runtime.IdentityHashCode (this); } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public virtual Db4objects.Drs.Tests.Data.Replicated GetLink() { return link; } public virtual void SetLink(Db4objects.Drs.Tests.Data.Replicated link) { this.link = link; } public override bool Equals(object o) { if (o == null) { return false; } if (!(o is Db4objects.Drs.Tests.Data.Replicated)) { return false; } return ((Db4objects.Drs.Tests.Data.Replicated)o).name.Equals(name); } public override int GetHashCode() { if (name == null) { return 0; } return name.GetHashCode(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/R3.cs000644 001750 001750 00000002124 11520622636 030622 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class R3 : R2 { internal R0 circle3; internal R4 r4; public virtual R0 GetCircle3() { return circle3; } public virtual void SetCircle3(R0 circle3) { this.circle3 = circle3; } public virtual R4 GetR4() { return r4; } public virtual void SetR4(R4 r4) { this.r4 = r4; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/R2.cs000644 001750 001750 00000002124 11520622636 030621 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class R2 : R1 { internal R0 circle2; internal R3 r3; public virtual R0 GetCircle2() { return circle2; } public virtual void SetCircle2(R0 circle2) { this.circle2 = circle2; } public virtual R3 GetR3() { return r3; } public virtual void SetR3(R3 r3) { this.r3 = r3; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ArrayHolder.cs000644 001750 001750 00000002531 11520622636 032554 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class ArrayHolder { public string _name; public Db4objects.Drs.Tests.Data.ArrayHolder[] _array; public Db4objects.Drs.Tests.Data.ArrayHolder[][] _arrayN; public ArrayHolder() { } public ArrayHolder(string name) { _name = name; } public override string ToString() { return _name + ", hashcode = " + GetHashCode(); } public virtual string GetName() { return _name; } public virtual Db4objects.Drs.Tests.Data.ArrayHolder[] Array() { return _array; } public virtual Db4objects.Drs.Tests.Data.ArrayHolder[][] ArrayN() { return _arrayN; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ListHolder.cs000644 001750 001750 00000002623 11520622636 032413 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class ListHolder { private string name; private IList list; public ListHolder() { } public ListHolder(string name) { this.name = name; } public virtual void Add(ListContent obj) { list.Add(obj); } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } public virtual IList GetList() { return list; } public virtual void SetList(IList list) { this.list = list; } public override string ToString() { return "name = " + name + ", list = " + list; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/ItemDates.cs000644 001750 001750 00000003750 11520622636 032223 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Sharpen.Util; namespace Db4objects.Drs.Tests.Data { public sealed class ItemDates { private DateTime date1; private DateTime date2; private DateTime[] dateArray; public ItemDates() { } public ItemDates(DateTime date1, DateTime date2) { this.SetDate1(date1); this.SetDate2(date2); this.SetDateArray(new DateTime[] { date1, date2 }); } public override bool Equals(object obj) { Db4objects.Drs.Tests.Data.ItemDates other = (Db4objects.Drs.Tests.Data.ItemDates) obj; if (!other.GetDate1().Equals(GetDate1())) { return false; } if (!other.GetDate2().Equals(GetDate2())) { return false; } return Arrays.Equals(GetDateArray(), other.GetDateArray()); } public override string ToString() { return "ItemDates [_date1=" + GetDate1() + ", _date2=" + GetDate2(); } public void SetDate1(DateTime date1) { this.date1 = date1; } public DateTime GetDate1() { return date1; } public void SetDate2(DateTime date2) { this.date2 = date2; } public DateTime GetDate2() { return date2; } public void SetDateArray(DateTime[] dateArray) { this.dateArray = dateArray; } public DateTime[] GetDateArray() { return dateArray; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/SimpleArrayContent.cs000644 001750 001750 00000002031 11520622636 034116 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Drs.Tests.Data { public class SimpleArrayContent { private string name; public SimpleArrayContent() { } public SimpleArrayContent(string name) { this.name = name; } public virtual string GetName() { return name; } public virtual void SetName(string name) { this.name = name; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Data/R1.cs000644 001750 001750 00000002124 11520622636 030620 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Data { public class R1 : R0 { internal R0 circle1; internal R2 r2; public virtual R0 GetCircle1() { return circle1; } public virtual void SetCircle1(R0 circle1) { this.circle1 = circle1; } public virtual R2 GetR2() { return r2; } public virtual void SetR2(R2 r2) { this.r2 = r2; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ComplexListTestCase.cs000644 001750 001750 00000011163 11520622636 033367 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ComplexListTestCase : DrsTestCase { public virtual void Test() { Store(A(), CreateList()); ReplicateAndTest(A(), B()); RoundTripTest(); } private void RoundTripTest() { ChangeInProviderB(); B().Provider().Commit(); ReplicateAndTest(B(), A()); } private void ChangeInProviderB() { SimpleListHolder simpleListHolder = (SimpleListHolder)GetOneInstance(B(), typeof( SimpleListHolder)); SimpleItem fooBaby = new SimpleItem(simpleListHolder, "foobaby"); B().Provider().StoreNew(fooBaby); simpleListHolder.Add(fooBaby); SimpleItem foo = GetItem(simpleListHolder, "foo"); foo.SetChild(fooBaby); B().Provider().Update(foo); B().Provider().Update(simpleListHolder.GetList()); B().Provider().Update(simpleListHolder); } private void ReplicateAndTest(IDrsProviderFixture source, IDrsProviderFixture target ) { ReplicateAll(source.Provider(), target.Provider()); EnsureContents(target, (SimpleListHolder)GetOneInstance(source, typeof(SimpleListHolder ))); } private void Store(IDrsProviderFixture fixture, SimpleListHolder listHolder) { ITestableReplicationProviderInside provider = fixture.Provider(); provider.StoreNew(listHolder); provider.StoreNew(GetItem(listHolder, "foo")); provider.StoreNew(GetItem(listHolder, "foobar")); provider.Commit(); EnsureContents(fixture, listHolder); } private void EnsureContents(IDrsProviderFixture actualFixture, SimpleListHolder expected ) { SimpleListHolder actual = (SimpleListHolder)GetOneInstance(actualFixture, typeof( SimpleListHolder)); IList expectedList = expected.GetList(); IList actualList = actual.GetList(); AssertListWithCycles(expectedList, actualList); } private void AssertListWithCycles(IList expectedList, IList actualList) { Assert.AreEqual(expectedList.Count, actualList.Count); for (int i = 0; i < expectedList.Count; ++i) { SimpleItem expected = (SimpleItem)expectedList[i]; SimpleItem actual = (SimpleItem)actualList[i]; AssertItem(expected, actual); } AssertCycle(actualList, "foo", "bar", 1); AssertCycle(actualList, "foo", "foobar", 1); AssertCycle(actualList, "foo", "baz", 2); } private void AssertCycle(IList list, string childName, string parentName, int level ) { SimpleItem foo = GetItem(list, childName); SimpleItem bar = GetItem(list, parentName); Assert.IsNotNull(foo); Assert.IsNotNull(bar); Assert.AreSame(foo, bar.GetChild(level)); Assert.AreSame(foo.GetParent(), bar.GetParent()); } private void AssertItem(SimpleItem expected, SimpleItem actual) { if (expected == null) { Assert.IsNull(actual); return; } Assert.AreEqual(expected.GetValue(), actual.GetValue()); AssertItem(expected.GetChild(), actual.GetChild()); } private SimpleItem GetItem(SimpleListHolder holder, string tbf) { return GetItem(holder.GetList(), tbf); } private SimpleItem GetItem(IList list, string tbf) { int itemIndex = list.IndexOf(new SimpleItem(tbf)); return (SimpleItem)(itemIndex >= 0 ? list[itemIndex] : null); } public virtual SimpleListHolder CreateList() { // list : {foo, bar, baz, foobar} // // baz -----+ // | // bar --> foo // ^ // | // foobar ----------+ SimpleListHolder listHolder = new SimpleListHolder("root"); SimpleItem foo = new SimpleItem(listHolder, "foo"); SimpleItem bar = new SimpleItem(listHolder, foo, "bar"); listHolder.Add(foo); listHolder.Add(bar); listHolder.Add(new SimpleItem(listHolder, bar, "baz")); listHolder.Add(new SimpleItem(listHolder, foo, "foobar")); return listHolder; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/DrsTestSuite.cs000644 001750 001750 00000004006 11520622636 032070 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Regression; namespace Db4objects.Drs.Tests { public abstract class DrsTestSuite : ReflectionTestSuite { public const bool RunOneSingleTest = false; protected override Type[] TestCases() { return new Type[] { typeof(DateReplicationTestCase), typeof(Db4objects.Drs.Tests.Foundation.AllTests ), typeof(TheSimplest), typeof(ReplicationEventTest), typeof(ReplicationProviderTest ), typeof(ReplicationAfterDeletionTest), typeof(SimpleArrayTest), typeof(SimpleParentChild ), typeof(ByteArrayTest), typeof(ComplexListTestCase), typeof(ListTest), typeof( R0to4Runner), typeof(ReplicationFeaturesMain), typeof(CollectionHandlerImplTest) , typeof(BidirectionalReplicationTestCase), typeof(TimestampTestCase), typeof(MapTest ), typeof(ArrayReplicationTest), typeof(SingleTypeCollectionReplicationTest), typeof( MixedTypesCollectionReplicationTest), typeof(TransparentActivationTestCase), typeof( DRS42Test), typeof(SameHashCodeTestCase) }; } // Simple // Collection // Complex // General //regression protected virtual Type[] Concat(Type[] x, Type[] y) { Collection4 c = new Collection4(x); c.AddAll(y); return (Type[])c.ToArray(new Type[c.Size()]); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/R0to4Runner.cs000644 001750 001750 00000015633 11520622640 031573 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o.Reflect; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class R0to4Runner : DrsTestCase { private const int Linkers = 4; public R0to4Runner() : base() { } // ------------------------------ FIELDS ------------------------------ // --------------------------- CONSTRUCTORS --------------------------- protected override void Clean() { Delete(A().Provider()); Delete(B().Provider()); } protected virtual void Delete(ITestableReplicationProviderInside provider) { ArrayList toDelete = new ArrayList(); IEnumerator rr = provider.GetStoredObjects(typeof(R0)).GetEnumerator(); while (rr.MoveNext()) { object o = rr.Current; IReflectClass claxx = ReplicationReflector().ForObject(o); SetFieldsToNull(o, claxx); toDelete.Add(o); } object commitObject = null; for (IEnumerator iterator = toDelete.GetEnumerator(); iterator.MoveNext(); ) { object o = iterator.Current; //System.out.println("o = " + o); provider.Delete(o); commitObject = o; } if (commitObject != null) { provider.Commit(); } else { provider.Commit(); } } private void CompareR4(ITestableReplicationProviderInside a, ITestableReplicationProviderInside b, bool isSameExpected) { IEnumerator it = a.GetStoredObjects(typeof(R4)).GetEnumerator(); while (it.MoveNext()) { string name = ((R4)it.Current).GetName(); IEnumerator it2 = b.GetStoredObjects(typeof(R4)).GetEnumerator(); bool found = false; while (it2.MoveNext()) { string name2 = ((R4)it2.Current).GetName(); if (name.Equals(name2)) { found = true; } } Assert.IsTrue(found == isSameExpected); } } private void ReplicateAllToB(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB) { Assert.AreEqual(Linkers * 5, ReplicateAll(peerA, peerB, false)); } private void EnsureCount(ITestableReplicationProviderInside provider, int linkers ) { EnsureCount(provider, typeof(R0), linkers * 5); EnsureCount(provider, typeof(R1), linkers * 4); EnsureCount(provider, typeof(R2), linkers * 3); EnsureCount(provider, typeof(R3), linkers * 2); EnsureCount(provider, typeof(R4), linkers * 1); } private void EnsureCount(ITestableReplicationProviderInside provider, Type clazz, int count) { IEnumerator instances = provider.GetStoredObjects(clazz).GetEnumerator(); int i = count; while (instances.MoveNext()) { object o = instances.Current; i--; } Assert.AreEqual(0, i); } private void EnsureR4Different(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB) { CompareR4(peerB, peerA, false); } private void EnsureR4Same(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB) { CompareR4(peerB, peerA, true); CompareR4(peerA, peerB, true); } private void Init(ITestableReplicationProviderInside peerA) { R0Linker lCircles = new R0Linker(); lCircles.SetNames("circles"); lCircles.LinkCircles(); lCircles.Store(peerA); R0Linker lList = new R0Linker(); lList.SetNames("list"); lList.LinkList(); lList.Store(peerA); R0Linker lThis = new R0Linker(); lThis.SetNames("this"); lThis.LinkThis(); lThis.Store(peerA); R0Linker lBack = new R0Linker(); lBack.SetNames("back"); lBack.LinkBack(); lBack.Store(peerA); peerA.Commit(); } private void ModifyR4(ITestableReplicationProviderInside provider) { object commitObject = null; IEnumerator it = provider.GetStoredObjects(typeof(R4)).GetEnumerator(); while (it.MoveNext()) { R4 r4 = (R4)it.Current; r4.SetName(r4.GetName() + "_"); provider.Update(r4); commitObject = r4; } provider.Commit(); } private int Replicate(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB) { return ReplicateAll(peerA, peerB, true); } private int ReplicateAll(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB, bool modifiedOnly) { IReplicationSession replication = Replication.Begin(peerA, peerB, null, _fixtures .reflector); IEnumerator it = modifiedOnly ? peerA.ObjectsChangedSinceLastReplication(typeof(R0 )).GetEnumerator() : peerA.GetStoredObjects(typeof(R0)).GetEnumerator(); int replicated = 0; while (it.MoveNext()) { R0 r0 = (R0)it.Current; replication.Replicate(r0); replicated++; } replication.Commit(); EnsureCount(peerA, Linkers); EnsureCount(peerB, Linkers); return replicated; } private void ReplicateNoneModified(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB) { Assert.IsTrue(Replicate(peerA, peerB) == 0); } private void ReplicateR4(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside peerB) { int replicatedObjectsCount = ReplicateAll(peerA, peerB, true); Assert.AreEqual(Linkers, replicatedObjectsCount); } private void SetFieldsToNull(object @object, IReflectClass claxx) { IReflectField[] fields; fields = claxx.GetDeclaredFields(); for (int i = 0; i < fields.Length; i++) { IReflectField field = fields[i]; if (field.IsStatic()) { continue; } if (field.IsTransient()) { continue; } field.Set(@object, null); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } SetFieldsToNull(@object, superclass); } public virtual void Test() { Init(A().Provider()); EnsureCount(A().Provider(), Linkers); ReplicateAllToB(A().Provider(), B().Provider()); ReplicateNoneModified(A().Provider(), B().Provider()); ModifyR4(A().Provider()); EnsureR4Different(A().Provider(), B().Provider()); ReplicateR4(A().Provider(), B().Provider()); EnsureR4Same(A().Provider(), B().Provider()); } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ReplicatingTwiceTestCase.cs000644 001750 001750 00000002461 11520622640 034276 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ReplicatingTwiceTestCase : DrsTestCase { public virtual void Test() { Pilot pilot = new Pilot("one", 1); A().Provider().StoreNew(pilot); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider(), null); pilot.SetName("modified"); A().Provider().Update(pilot); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider(), null); Pilot pilotFromB = (Pilot)GetOneInstance(B(), typeof(Pilot)); Assert.AreEqual("modified", pilotFromB.Name()); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4oDrsTestSuiteBuilder.cs000644 001750 001750 00000004240 11520622636 034110 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class Db4oDrsTestSuiteBuilder : ITestSuiteBuilder { public static void Main(string[] args) { new ConsoleTestRunner(new Db4oDrsTestSuiteBuilder()).Run(); } public virtual IEnumerator GetEnumerator() { if (false) { return new DrsTestSuiteBuilder(new Db4oDrsFixture("db4o-a"), new Db4oDrsFixture("db4o-b" ), typeof(Db4oDrsTestSuite)).GetEnumerator(); } if (false) { return new DrsTestSuiteBuilder(new Db4oClientServerDrsFixture("db4o-cs-a", unchecked( (int)(0xdb40))), new Db4oClientServerDrsFixture("db4o-cs-b", 4455), typeof(Db4oDrsTestSuite )).GetEnumerator(); } return Iterators.Concat(Iterators.Concat(new DrsTestSuiteBuilder(new Db4oDrsFixture ("db4o-a"), new Db4oDrsFixture("db4o-b"), typeof(Db4oDrsTestSuite)).GetEnumerator (), new DrsTestSuiteBuilder(new Db4oClientServerDrsFixture("db4o-cs-a", unchecked( (int)(0xdb40))), new Db4oClientServerDrsFixture("db4o-cs-b", 4455), typeof(Db4oDrsTestSuite )).GetEnumerator()), Iterators.Concat(new DrsTestSuiteBuilder(new Db4oDrsFixture ("db4o-a"), new Db4oClientServerDrsFixture("db4o-cs-b", 4455), typeof(Db4oDrsTestSuite )).GetEnumerator(), new DrsTestSuiteBuilder(new Db4oClientServerDrsFixture("db4o-cs-a" , 4455), new Db4oDrsFixture("db4o-b"), typeof(Db4oDrsTestSuite)).GetEnumerator() )); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ReplicationFeaturesMain.cs000644 001750 001750 00000047735 11520622640 034256 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Db4o.Foundation; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; using Db4objects.Drs.Tests.Foundation; using Sharpen; namespace Db4objects.Drs.Tests { public class ReplicationFeaturesMain : DrsTestCase { private const bool Debug = false; private static readonly string AStuff = "A"; private static readonly string BStuff = "B"; private readonly Set4 _setA = new Set4(1); private readonly Set4 _setB = new Set4(1); private readonly Set4 _setBoth = new Set4(2); private readonly Set4 None = Set4.EmptySet; private Set4 _direction; private Set4 _containersToQueryFrom; private Set4 _containersWithNewObjects; private Set4 _containersWithChangedObjects; private Set4 _containersWithDeletedObjects; private Set4 _containerStateToPrevail; private string _intermittentErrors = string.Empty; private int _testCombination; private static void Fail(string @string) { Sharpen.Runtime.Err.WriteLine(@string); throw new Exception(@string); } private void ReplicateQueryingFrom(IReplicationSession replication, IReplicationProvider origin, IReplicationProvider other) { ReplicationConflictException exception = null; IEnumerator changes = origin.ObjectsChangedSinceLastReplication().GetEnumerator(); while (changes.MoveNext()) { object changed = changes.Current; try { replication.Replicate(changed); } catch (ReplicationConflictException e) { exception = e; } } if (exception != null) { throw exception; } } private bool IsReplicationConflictExceptionExpectedReplicatingModifications() { return WasConflictReplicatingModifications() && IsDefaultReplicationBehaviorAllowed (); } private bool IsReplicationConflictExceptionExpectedReplicatingDeletions() { return WasConflictReplicatingDeletions() && IsDefaultReplicationBehaviorAllowed(); } private bool WasConflictReplicatingDeletions() { if (_containersWithDeletedObjects.Size() != 1) { return false; } string container = (string)FirstContainerWithDeletedObjects(); if (HasChanges(Other(container))) { return true; } if (_direction.Size() != 1) { return false; } return _direction.Contains(container); } private string FirstContainerWithDeletedObjects() { return First(_containersWithDeletedObjects.GetEnumerator()); } private bool IsDefaultReplicationBehaviorAllowed() { return _containerStateToPrevail != null && _containerStateToPrevail.IsEmpty(); } private void ChangeObject(ITestableReplicationProviderInside container, string name , string newName) { Replicated obj = Find(container, name); if (obj == null) { return; } obj.SetName(newName); container.Update(obj); Out("CHANGED: " + container + ": " + name + " => " + newName + " - " + obj); } private void CheckEmpty(ITestableReplicationProviderInside provider) { if (provider.GetStoredObjects(typeof(Replicated)).GetEnumerator().MoveNext()) { throw new Exception(provider.GetName() + " is not empty"); } } private int checkNameCount = 0; private void CheckName(ITestableReplicationProviderInside container, string name, bool isExpected) { Out(string.Empty); Out(name + (isExpected ? " " : " NOT") + " expected in container " + ContainerName (container)); Replicated obj = Find(container, name); Out(checkNameCount.ToString()); checkNameCount++; if (isExpected) { Assert.IsNotNull(obj, "Expecting: " + name + " in " + ContainerName(container)); } else { Assert.IsNull(obj); } } private string ContainerName(ITestableReplicationProviderInside container) { return container == A().Provider() ? "A" : "B"; } private void CheckNames() { CheckNames(AStuff, AStuff); CheckNames(AStuff, BStuff); CheckNames(BStuff, AStuff); CheckNames(BStuff, BStuff); } private void CheckNames(string origin, string inspected) { CheckName(Container(inspected), "oldFrom" + origin, IsOldNameExpected(inspected)); CheckName(Container(inspected), "newFrom" + origin, IsNewNameExpected(origin, inspected )); CheckName(Container(inspected), "oldFromAChangedIn" + origin, IsChangedNameExpected (origin, inspected)); CheckName(Container(inspected), "oldFromBChangedIn" + origin, IsChangedNameExpected (origin, inspected)); } private ITestableReplicationProviderInside Container(string aOrB) { return aOrB.Equals(AStuff) ? A().Provider() : B().Provider(); } private void DeleteObject(ITestableReplicationProviderInside container, string name ) { Replicated obj = Find(container, name); container.Delete(obj); } private void DoIt() { InitState(); PrintProvidersContent("before changes"); PerformChanges(); PrintProvidersContent("after changes"); IReplicationEventListener listener = new _IReplicationEventListener_167(this); //Default replication behaviour. IReplicationSession replication = new GenericReplicationSession(A().Provider(), B ().Provider(), listener, _fixtures.reflector); if (_direction.Size() == 1) { if (_direction.Contains(AStuff)) { replication.SetDirection(B().Provider(), A().Provider()); } if (_direction.Contains(BStuff)) { replication.SetDirection(A().Provider(), B().Provider()); } } Out("DIRECTION: " + _direction); bool successful = TryToReplicate(replication); replication.Commit(); PrintProvidersContent("after replication"); if (successful) { CheckNames(); } Clean(); } private sealed class _IReplicationEventListener_167 : IReplicationEventListener { public _IReplicationEventListener_167(ReplicationFeaturesMain _enclosing) { this._enclosing = _enclosing; } public void OnReplicate(IReplicationEvent e) { if (this._enclosing._containerStateToPrevail == null) { e.OverrideWith(null); return; } if (this._enclosing._containerStateToPrevail.IsEmpty()) { return; } IObjectState @override = this._enclosing._containerStateToPrevail.Contains(ReplicationFeaturesMain .AStuff) ? e.StateInProviderA() : e.StateInProviderB(); e.OverrideWith(@override); } private readonly ReplicationFeaturesMain _enclosing; } private void PrintProvidersContent(string msg) { return; Sharpen.Runtime.Out.WriteLine("*** " + msg); PrintProviderContent(A().Provider()); PrintProviderContent(B().Provider()); } private void PrintProviderContent(ITestableReplicationProviderInside provider) { IObjectSet storedObjects = provider.GetStoredObjects(typeof(Replicated)); Sharpen.Runtime.Out.WriteLine("PROVIDER: " + provider); while (storedObjects.HasNext()) { object @object = storedObjects.Next(); Sharpen.Runtime.Out.WriteLine("-> " + @object + " - c:" + CreationTime(provider, @object) + " v:" + Version(provider, @object)); } } private long Version(ITestableReplicationProviderInside provider, object obj) { return provider.ObjectVersion(obj); } private long CreationTime(ITestableReplicationProviderInside provider, object obj ) { return provider.CreationTime(obj); } private bool TryToReplicate(IReplicationSession replication) { try { Replicate(replication, AStuff); Replicate(replication, BStuff); Assert.IsFalse(IsReplicationConflictExceptionExpectedReplicatingModifications()); } catch (ReplicationConflictException) { Out("Conflict exception during modification replication."); Assert.IsTrue(IsReplicationConflictExceptionExpectedReplicatingModifications()); return false; } try { if (IsDeletionReplicationTriggered()) { replication.ReplicateDeletions(typeof(Replicated)); } Assert.IsFalse(IsReplicationConflictExceptionExpectedReplicatingDeletions()); } catch (ReplicationConflictException) { Out("Conflict exception during deletion replication."); Assert.IsTrue(IsReplicationConflictExceptionExpectedReplicatingDeletions()); return false; } return true; } private void Replicate(IReplicationSession replication, string originName) { IReplicationProvider origin = Container(originName); IReplicationProvider destination = Container(Other(originName)); if (!_containersToQueryFrom.Contains(originName)) { return; } ReplicateQueryingFrom(replication, origin, destination); } private Replicated Find(ITestableReplicationProviderInside container, string name ) { IEnumerator storedObjects = container.GetStoredObjects(typeof(Replicated)).GetEnumerator (); int resultCount = 0; Replicated result = null; while (storedObjects.MoveNext()) { Replicated replicated = (Replicated)storedObjects.Current; if (replicated == null) { throw new Exception(); } if (name.Equals(replicated.GetName())) { result = replicated; resultCount++; } } if (resultCount > 1) { Fail("At most one object with name " + name + " was expected."); } return result; } private bool HasChanges(string container) { return _containersWithChangedObjects.Contains(container); } private bool HasDeletions(string container) { return _containersWithDeletedObjects.Contains(container); } private void InitState() { CheckEmpty(A().Provider()); CheckEmpty(B().Provider()); A().Provider().StoreNew(new Replicated("oldFromA")); B().Provider().StoreNew(new Replicated("oldFromB")); A().Provider().Commit(); B().Provider().Commit(); PrintProvidersContent("init state"); IReplicationSession replication = new GenericReplicationSession(A().Provider(), B ().Provider(), null, _fixtures.reflector); ReplicateQueryingFrom(replication, A().Provider(), B().Provider()); ReplicateQueryingFrom(replication, B().Provider(), A().Provider()); replication.Commit(); } private bool IsChangedNameExpected(string changedContainer, string inspectedContainer ) { if (!HasChanges(changedContainer)) { return false; } if (IsDeletionExpected(inspectedContainer)) { return false; } if (IsDeletionExpected(changedContainer)) { return false; } if (inspectedContainer.Equals(changedContainer)) { return !DidReceiveRemoteState(inspectedContainer); } return DidReceiveRemoteState(inspectedContainer); } private bool DidReceiveRemoteState(string inspectedContainer) { string other = Other(inspectedContainer); if (IsDirectionTo(other)) { return false; } if (_containerStateToPrevail == null) { return false; } if (_containerStateToPrevail.Contains(inspectedContainer)) { return false; } if (_containerStateToPrevail.Contains(other)) { if (IsModificationReplicationTriggered()) { return true; } if (IsDeletionReplicationTriggered()) { return true; } return false; } //No override to prevail. Default replication behavior. if (HasChanges(inspectedContainer)) { return false; } //A conflict would have been ignored long ago. return IsModificationReplicationTriggered(); } private bool IsDeletionReplicationTriggered() { return !_containersWithDeletedObjects.IsEmpty(); } private bool IsDirectionTo(string container) { return _direction.Size() == 1 && _direction.Contains(container); } private bool WasConflictReplicatingModifications() { return WasConflictWhileReplicatingModificationsQueryingFrom(AStuff) || WasConflictWhileReplicatingModificationsQueryingFrom (BStuff); } private bool IsModificationReplicationTriggered() { return WasModificationReplicationTriggeredQueryingFrom(AStuff) || WasModificationReplicationTriggeredQueryingFrom (BStuff); } private bool IsDeletionExpected(string inspectedContainer) { if (_containerStateToPrevail == null) { return HasDeletions(inspectedContainer); } if (_containerStateToPrevail.Contains(inspectedContainer)) { return HasDeletions(inspectedContainer); } string other = Other(inspectedContainer); if (IsDirectionTo(other)) { return HasDeletions(inspectedContainer); } if (_containerStateToPrevail.Contains(other)) { return HasDeletions(other); } //_containerStateToPrevail is empty (default replication behaviour) return IsDeletionReplicationTriggered(); } private bool IsNewNameExpected(string origin, string inspected) { if (!_containersWithNewObjects.Contains(origin)) { return false; } if (origin.Equals(inspected)) { return true; } if (_containerStateToPrevail == null) { return false; } if (_containerStateToPrevail.Contains(inspected)) { return false; } if (!_containersToQueryFrom.Contains(origin)) { return false; } return _direction.Contains(inspected); } private bool IsOldNameExpected(string inspectedContainer) { if (IsDeletionExpected(inspectedContainer)) { return false; } if (IsChangedNameExpected(AStuff, inspectedContainer)) { return false; } if (IsChangedNameExpected(BStuff, inspectedContainer)) { return false; } return true; } private string Other(string aOrB) { return aOrB.Equals(AStuff) ? BStuff : AStuff; } private void PerformChanges() { if (_containersWithNewObjects.Contains(AStuff)) { A().Provider().StoreNew(new Replicated("newFromA")); } if (_containersWithNewObjects.Contains(BStuff)) { B().Provider().StoreNew(new Replicated("newFromB")); } if (HasDeletions(AStuff)) { DeleteObject(A().Provider(), "oldFromA"); DeleteObject(A().Provider(), "oldFromB"); } if (HasDeletions(BStuff)) { DeleteObject(B().Provider(), "oldFromA"); DeleteObject(B().Provider(), "oldFromB"); } if (HasChanges(AStuff)) { ChangeObject(A().Provider(), "oldFromA", "oldFromAChangedInA"); ChangeObject(A().Provider(), "oldFromB", "oldFromBChangedInA"); } if (HasChanges(BStuff)) { ChangeObject(B().Provider(), "oldFromA", "oldFromAChangedInB"); ChangeObject(B().Provider(), "oldFromB", "oldFromBChangedInB"); } A().Provider().Commit(); B().Provider().Commit(); } private string Print(Set4 containerSet) { if (containerSet == null) { return "null"; } if (containerSet.IsEmpty()) { return "NONE"; } if (containerSet.Size() == 2) { return "BOTH"; } return First(containerSet); } private string First(Set4 containerSet) { return First(containerSet.GetEnumerator()); } private string First(IEnumerator iterator) { return (string)Iterators.Next(iterator); } private void RunCurrentCombination() { _testCombination++; Out(string.Empty + _testCombination + " ================================="); PrintCombination(); if (_testCombination < 0) { //Use this when debugging to skip some combinations and avoid waiting. return; } int _errors = 0; while (true) { try { DoIt(); break; } catch (Exception rx) { _errors++; if (_errors == 1) { Sleep(100); PrintCombination(); throw; } } } if (_errors > 0) { _intermittentErrors += "\n\t Combination: " + _testCombination + " (" + _errors + " errors)"; } } public virtual void Test() { long start = Runtime.CurrentTimeMillis(); ActualTest(); long stop = Runtime.CurrentTimeMillis(); long duration = stop - start; Sharpen.Runtime.Out.WriteLine("ReplicationFeaturesMain takes " + duration + "ms"); Sharpen.Runtime.Out.WriteLine("Run combinations " + _testCombination); } private static void Out(string @string) { } private void PrintCombination() { return; Out(string.Empty + _testCombination + " ================================="); Out("Deleted Objects In: " + Print(_containersWithDeletedObjects)); Out("Direction: To " + Print(_direction)); Out("Querying From: " + Print(_containersToQueryFrom)); Out("New Objects In: " + Print(_containersWithNewObjects)); Out("Changed Objects In: " + Print(_containersWithChangedObjects)); Out("Prevailing State: " + Print(_containerStateToPrevail)); } protected virtual void ActualTest() { Clean(); _setA.Add(AStuff); _setB.Add(BStuff); _setBoth.AddAll(_setA); _setBoth.AddAll(_setB); _testCombination = 0; TstWithDeletedObjectsIn(None); TstWithDeletedObjectsIn(_setA); TstWithDeletedObjectsIn(_setB); TstWithDeletedObjectsIn(_setBoth); if (_intermittentErrors.Length > 0) { Sharpen.Runtime.Err.WriteLine("Intermittent errors found in test combinations:" + _intermittentErrors); Assert.IsTrue(false); } } private void TstWithDeletedObjectsIn(Set4 containers) { _containersWithDeletedObjects = containers; TstDirection(_setA); TstDirection(_setB); TstDirection(_setBoth); } private void TstDirection(Set4 direction) { _direction = direction; TstQueryingFrom(_setA); TstQueryingFrom(_setB); TstQueryingFrom(_setBoth); } private void TstQueryingFrom(Set4 containersToQueryFrom) { _containersToQueryFrom = containersToQueryFrom; TstWithNewObjectsIn(None); TstWithNewObjectsIn(_setA); TstWithNewObjectsIn(_setB); TstWithNewObjectsIn(_setBoth); } private void TstWithNewObjectsIn(Set4 containersWithNewObjects) { _containersWithNewObjects = containersWithNewObjects; TstWithChangedObjectsIn(None); TstWithChangedObjectsIn(_setA); TstWithChangedObjectsIn(_setB); TstWithChangedObjectsIn(_setBoth); } private void TstWithChangedObjectsIn(Set4 containers) { _containersWithChangedObjects = containers; TstWithContainerStateToPrevail(_setA); return; TstWithContainerStateToPrevail(None); TstWithContainerStateToPrevail(_setA); TstWithContainerStateToPrevail(_setB); TstWithContainerStateToPrevail(null); } private void TstWithContainerStateToPrevail(Set4 containers) { _containerStateToPrevail = containers; RunCurrentCombination(); } private bool WasConflictWhileReplicatingModificationsQueryingFrom(string container ) { if (!WasModificationReplicationTriggeredQueryingFrom(container)) { return false; } if (_containersWithChangedObjects.ContainsAll(_direction)) { return true; } return HasDeletions(Other(container)); } private bool WasModificationReplicationTriggeredQueryingFrom(string container) { if (!_containersToQueryFrom.Contains(container)) { return false; } if (_containersWithDeletedObjects.Contains(container)) { return false; } return _containersWithChangedObjects.Contains(container); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/R0Linker.cs000644 001750 001750 00000003727 11520622640 031120 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Drs.Inside; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { internal class R0Linker { internal R0 r0; internal R1 r1; internal R2 r2; internal R3 r3; internal R4 r4; internal R0Linker() { r0 = new R0(); r1 = new R1(); r2 = new R2(); r3 = new R3(); r4 = new R4(); } internal virtual void SetNames(string name) { r0.SetName("0" + name); r1.SetName("1" + name); r2.SetName("2" + name); r3.SetName("3" + name); r4.SetName("4" + name); } internal virtual void LinkCircles() { LinkList(); r1.SetCircle1(r0); r2.SetCircle2(r0); r3.SetCircle3(r0); r4.SetCircle4(r0); } internal virtual void LinkList() { r0.SetR1(r1); r1.SetR2(r2); r2.SetR3(r3); r3.SetR4(r4); } internal virtual void LinkThis() { r0.SetR0(r0); r1.SetR1(r1); r2.SetR2(r2); r3.SetR3(r3); r4.SetR4(r4); } internal virtual void LinkBack() { r1.SetR0(r0); r2.SetR1(r1); r3.SetR2(r2); r4.SetR3(r3); } public virtual void Store(ITestableReplicationProviderInside provider) { provider.StoreNew(r4); provider.StoreNew(r3); provider.StoreNew(r2); provider.StoreNew(r1); provider.StoreNew(r0); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/DrsFixture.cs000644 001750 001750 00000002645 11520622636 031574 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class DrsFixture { public readonly IDrsProviderFixture a; public readonly IDrsProviderFixture b; public readonly IReflector reflector; public DrsFixture(IDrsProviderFixture fixtureA, IDrsProviderFixture fixtureB) : this (fixtureA, fixtureB, null) { } public DrsFixture(IDrsProviderFixture fixtureA, IDrsProviderFixture fixtureB, IReflector reflector) { if (null == fixtureA) { throw new ArgumentException("fixtureA"); } if (null == fixtureB) { throw new ArgumentException("fixtureB"); } a = fixtureA; b = fixtureB; this.reflector = reflector; } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/SingleTypeCollectionReplicationTest.cs000644 001750 001750 00000015012 11520622640 036532 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using Db4oUnit; using Db4oUnit.Fixtures; using Db4objects.Db4o.Config; using Db4objects.Db4o.TA; using Db4objects.Drs.Db4o; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; using Sharpen.Util; namespace Db4objects.Drs.Tests { public class SingleTypeCollectionReplicationTest : FixtureBasedTestSuite { private static readonly FixtureVariable TransparentActivationFixture = FixtureVariable .NewInstance("Transparent Activation"); public override IFixtureProvider[] FixtureProviders() { return new IFixtureProvider[] { new SubjectFixtureProvider(new SingleTypeCollectionReplicationTest.CollectionHolderFactory [] { Collection1(), Collection2(), Collection3() }), new SimpleFixtureProvider(TransparentActivationFixture , (object[])LabeledObject.ForObjects(new object[] { false, true })) }; } public abstract class CollectionHolderFactory : ILabeled { public abstract CollectionHolder NewCollectionHolder(); public abstract string Label(); } private SingleTypeCollectionReplicationTest.CollectionHolderFactory Collection1() { return new _CollectionHolderFactory_56(this); } private sealed class _CollectionHolderFactory_56 : SingleTypeCollectionReplicationTest.CollectionHolderFactory { public _CollectionHolderFactory_56(SingleTypeCollectionReplicationTest _enclosing ) { this._enclosing = _enclosing; } public override CollectionHolder NewCollectionHolder() { return this._enclosing.Initialize(new CollectionHolder("Hashtable", new Hashtable (), new HashSet(), new ArrayList())); } public override string Label() { return "Hashtable"; } private readonly SingleTypeCollectionReplicationTest _enclosing; } private SingleTypeCollectionReplicationTest.CollectionHolderFactory Collection2() { return new _CollectionHolderFactory_74(this); } private sealed class _CollectionHolderFactory_74 : SingleTypeCollectionReplicationTest.CollectionHolderFactory { public _CollectionHolderFactory_74(SingleTypeCollectionReplicationTest _enclosing ) { this._enclosing = _enclosing; } public override CollectionHolder NewCollectionHolder() { return this._enclosing.Initialize(new CollectionHolder("HashMap", new Dictionary< string, string>(), new HashSet(), new List())); } public override string Label() { return "HashMap"; } private readonly SingleTypeCollectionReplicationTest _enclosing; } private SingleTypeCollectionReplicationTest.CollectionHolderFactory Collection3() { return new _CollectionHolderFactory_92(this); } private sealed class _CollectionHolderFactory_92 : SingleTypeCollectionReplicationTest.CollectionHolderFactory { public _CollectionHolderFactory_92(SingleTypeCollectionReplicationTest _enclosing ) { this._enclosing = _enclosing; } public override CollectionHolder NewCollectionHolder() { return this._enclosing.Initialize(new CollectionHolder("TreeMap", new SortedList< string, string>(), new HashSet(), new ArrayList())); } public override string Label() { return "TreeMap"; } private readonly SingleTypeCollectionReplicationTest _enclosing; } private CollectionHolder Initialize(CollectionHolder h1) { h1.Map()["1"] = "one"; h1.Map()["2"] = "two"; h1.Set().Add("two"); h1.List().Add("three"); return h1; } public override Type[] TestUnits() { return new Type[] { typeof(SingleTypeCollectionReplicationTest.TestUnit) }; } public class TestUnit : DrsTestCase { protected override void Configure(IConfiguration config) { LabeledObject transparentActivation = (LabeledObject)TransparentActivationFixture .Value; if ((bool)transparentActivation.Value()) { config.Add(new TransparentActivationSupport()); } } public virtual void Test() { CollectionHolder h1 = Subject(); StoreNewAndCommit(A().Provider(), h1); ReplicateAll(A().Provider(), B().Provider()); IEnumerator it = B().Provider().GetStoredObjects(typeof(CollectionHolder)).GetEnumerator (); Assert.IsTrue(it.MoveNext()); CollectionHolder replica = (CollectionHolder)it.Current; B().Provider().Activate(replica); AssertSameClassIfDb4o(h1.Map(), replica.Map()); foreach (object key in h1.Map().Keys) { B().Provider().Activate(replica.Map()); Assert.AreEqual(h1.Map()[key], replica.Map()[key]); } AssertSameClassIfDb4o(h1.Set(), replica.Set()); foreach (object element in h1.Set()) { Assert.IsTrue(replica.Set().Contains(element)); } AssertSameClassIfDb4o(h1.List(), replica.List()); Assert.AreEqual(h1.List().Count, replica.List().Count); CollectionAssert.AreEqual(h1.List(), replica.List()); } private CollectionHolder Subject() { SingleTypeCollectionReplicationTest.CollectionHolderFactory factory = (SingleTypeCollectionReplicationTest.CollectionHolderFactory )SubjectFixtureProvider.Value(); return factory.NewCollectionHolder(); } private void AssertSameClassIfDb4o(object expectedInstance, object actualInstance ) { if (!IsDb4oProvider(A())) { return; } if (!IsDb4oProvider(B())) { return; } Assert.AreSame(expectedInstance.GetType(), actualInstance.GetType()); } private bool IsDb4oProvider(IDrsProviderFixture fixture) { return fixture.Provider() is IDb4oReplicationProvider; } private void StoreNewAndCommit(ITestableReplicationProviderInside provider, CollectionHolder h1) { provider.StoreNew(h1); provider.Activate(h1); provider.Commit(); } } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/BidirectionalReplicationTestCase.cs000644 001750 001750 00000006320 11520622636 036006 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class BidirectionalReplicationTestCase : DrsTestCase { public virtual void TestObjectsAreOnlyReplicatedOnce() { ITestableReplicationProviderInside providerA = A().Provider(); ITestableReplicationProviderInside providerB = B().Provider(); StoreNewPilotIn(providerA); int replicatedObjects = ReplicateBidirectional(providerA, providerB, null); Assert.AreEqual(1, replicatedObjects); ModifyPilotIn(providerA, "modifiedInA"); replicatedObjects = ReplicateBidirectional(providerA, providerB, typeof(Pilot)); Assert.AreEqual(1, replicatedObjects); ModifyPilotIn(providerB, "modifiedInB"); replicatedObjects = ReplicateBidirectional(providerA, providerB, null); Assert.AreEqual(1, replicatedObjects); StoreNewPilotIn(providerA); StoreNewPilotIn(providerB); replicatedObjects = ReplicateBidirectional(providerA, providerB, typeof(Pilot)); Assert.AreEqual(2, replicatedObjects); } private void ModifyPilotIn(ITestableReplicationProviderInside provider, string newName ) { Pilot pilot; pilot = (Pilot)provider.GetStoredObjects(typeof(Pilot)).Next(); pilot.SetName(newName); provider.Update(pilot); provider.Commit(); provider.WaitForPreviousCommits(); } private int ReplicateBidirectional(ITestableReplicationProviderInside providerA, ITestableReplicationProviderInside providerB, Type clazz) { int replicatedObjects = 0; IReplicationSession replicationSession = Replication.Begin(providerA, providerB, null, _fixtures.reflector); IObjectSet changedInA = clazz == null ? providerA.ObjectsChangedSinceLastReplication () : providerA.ObjectsChangedSinceLastReplication(clazz); foreach (object obj in changedInA) { replicatedObjects++; replicationSession.Replicate(obj); } IObjectSet changedInB = clazz == null ? providerB.ObjectsChangedSinceLastReplication () : providerB.ObjectsChangedSinceLastReplication(clazz); foreach (object obj in changedInB) { replicatedObjects++; replicationSession.Replicate(obj); } replicationSession.Commit(); return replicatedObjects; } private void StoreNewPilotIn(ITestableReplicationProviderInside provider) { Pilot pilot = new Pilot(); provider.StoreNew(pilot); provider.Commit(); provider.WaitForPreviousCommits(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4oDrsTestSuite.cs000644 001750 001750 00000002217 11520622636 032603 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Extensions; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Db4o; using Db4objects.Drs.Tests.Dotnet; namespace Db4objects.Drs.Tests { public partial class Db4oDrsTestSuite : VersantDrsTestSuite, IDb4oTestCase { private Type[] SpecificTestCases() { return new Type[] { typeof(StructTestCase), typeof(UntypedFieldTestCase), typeof( PartialCollectionReplicationTestCase), typeof(TheSimplestWithCallConstructors) }; } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/MixedTypesCollectionReplicationTest.cs000644 001750 001750 00000007076 11520622640 036555 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class MixedTypesCollectionReplicationTest : DrsTestCase { protected virtual void ActualTest() { if (!A().Provider().SupportsHybridCollection()) { return; } if (!B().Provider().SupportsHybridCollection()) { return; } CollectionHolder h1 = new CollectionHolder("h1"); CollectionHolder h2 = new CollectionHolder("h2"); h1.Map()["key"] = "value"; h1.Map()["key2"] = h1; h1.Map()[h1] = "value2"; h2.Map()["key"] = h1; h2.Map()[h2] = h1; h1.List().Add("one"); h1.List().Add(h1); h2.List().Add("two"); h2.List().Add(h1); h2.List().Add(h2); h1.Set().Add("one"); h1.Set().Add(h1); h2.Set().Add("two"); h2.Set().Add(h1); h2.Set().Add(h2); B().Provider().StoreNew(h2); B().Provider().StoreNew(h1); IReplicationSession replication = new GenericReplicationSession(A().Provider(), B ().Provider()); replication.Replicate(h2); //Traverses to h1. replication.Commit(); IEnumerator objects = A().Provider().GetStoredObjects(typeof(CollectionHolder)).GetEnumerator (); Check(NextCollectionHolder(objects), h1, h2); Check(NextCollectionHolder(objects), h1, h2); } private CollectionHolder NextCollectionHolder(IEnumerator objects) { Assert.IsTrue(objects.MoveNext()); return (CollectionHolder)objects.Current; } private void Check(CollectionHolder holder, CollectionHolder original1, CollectionHolder original2) { Assert.IsTrue(holder != original1); Assert.IsTrue(holder != original2); if (holder.Name().Equals("h1")) { CheckH1(holder); } else { CheckH2(holder); } } private void CheckH1(CollectionHolder holder) { Assert.AreEqual("value", holder.Map()["key"]); Assert.AreEqual(holder, holder.Map()["key2"]); Assert.AreEqual("value2", holder.Map()[holder]); Assert.AreEqual("one", holder.List()[0]); Assert.AreEqual(holder, holder.List()[1]); Assert.IsTrue(holder.Set().Contains("one")); Assert.IsTrue(holder.Set().Contains(holder)); } private void CheckH2(CollectionHolder holder) { Assert.AreEqual("h1", ((CollectionHolder)holder.Map()["key"]).Name()); Assert.AreEqual("h1", ((CollectionHolder)holder.Map()[holder]).Name()); Assert.AreEqual("two", holder.List()[0]); Assert.AreEqual("h1", ((CollectionHolder)holder.List()[1]).Name()); Assert.AreEqual(holder, holder.List()[2]); Assert.IsTrue(holder.Set().Remove("two")); Assert.IsTrue(holder.Set().Remove(holder)); CollectionHolder remaining = NextCollectionHolder(holder.Set().GetEnumerator()); Assert.AreEqual("h1", remaining.Name()); } public virtual void Test() { ActualTest(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Foundation/000755 001750 001750 00000000000 11520622056 031241 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Foundation/Set4Testcase.cs000644 001750 001750 00000002733 11520622636 034114 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Tests.Foundation; namespace Db4objects.Drs.Tests.Foundation { public class Set4Testcase : ITestCase { public virtual void TestSingleElementIteration() { Set4 set = NewSet("first"); Assert.AreEqual("first", Iterators.Next(set.GetEnumerator())); } public virtual void TestContainsAll() { Set4 set = NewSet("42"); set.Add("foo"); Assert.IsTrue(set.ContainsAll(NewSet("42"))); Assert.IsTrue(set.ContainsAll(NewSet("foo"))); Assert.IsTrue(set.ContainsAll(set)); Set4 other = new Set4(set); other.Add("bar"); Assert.IsFalse(set.ContainsAll(other)); } private Set4 NewSet(string firstElement) { Set4 set = new Set4(); set.Add(firstElement); return set; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Foundation/Set4.cs000644 001750 001750 00000003747 11520622636 032426 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Db4o.Foundation; namespace Db4objects.Drs.Tests.Foundation { public class Set4 : IEnumerable { public static readonly Db4objects.Drs.Tests.Foundation.Set4 EmptySet = new Db4objects.Drs.Tests.Foundation.Set4 (0); private readonly Hashtable4 _table; public Set4() { _table = new Hashtable4(); } public Set4(int size) { _table = new Hashtable4(size); } public Set4(IEnumerable keys) : this() { AddAll(keys); } public virtual void Add(object element) { _table.Put(element, element); } public virtual void AddAll(IEnumerable other) { IEnumerator i = other.GetEnumerator(); while (i.MoveNext()) { Add(i.Current); } } public virtual bool IsEmpty() { return _table.Size() == 0; } public virtual int Size() { return _table.Size(); } public virtual bool Contains(object element) { return _table.Get(element) != null; } public virtual bool ContainsAll(Db4objects.Drs.Tests.Foundation.Set4 other) { return _table.ContainsAllKeys(other); } public virtual IEnumerator GetEnumerator() { return _table.Keys(); } public override string ToString() { return Iterators.Join(GetEnumerator(), "[", "]", ", "); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Foundation/AllTests.cs000644 001750 001750 00000002170 11520622636 033327 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Drs.Tests.Foundation; namespace Db4objects.Drs.Tests.Foundation { public class AllTests : ReflectionTestSuite { public static void Main(string[] args) { new Db4objects.Drs.Tests.Foundation.AllTests().Run(); } protected override Type[] TestCases() { return new Type[] { typeof(ObjectSetCollection4FacadeTestCase), typeof(Set4Testcase ), typeof(SignatureTestCase) }; } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Foundation/SignatureTestCase.cs000644 001750 001750 00000002436 11520622636 035117 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Encoding; using Db4objects.Drs.Foundation; namespace Db4objects.Drs.Tests.Foundation { public class SignatureTestCase : ITestCase { public virtual void Test() { StatefulBuffer writer = new StatefulBuffer(null, 300); string stringRepresentation = SignatureGenerator.GenerateSignature(); new LatinStringIO().Write(writer, stringRepresentation); Signature signature = new Signature(writer.GetWrittenBytes()); Assert.AreEqual(stringRepresentation, signature.ToString()); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/CustomArrayListTestCase.cs000644 001750 001750 00000002620 11520622636 034227 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class CustomArrayListTestCase : DrsTestCase { public virtual void Test() { NamedList original = new NamedList("foo"); original.Add("bar"); A().Provider().StoreNew(original); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider()); IEnumerator iterator = B().Provider().GetStoredObjects(typeof(NamedList)).GetEnumerator (); Assert.IsTrue(iterator.MoveNext()); NamedList replicated = (NamedList)iterator.Current; Assert.AreEqual(original.Name(), replicated.Name()); CollectionAssert.AreEqual(original, replicated); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/TimestampTestCase.cs000644 001750 001750 00000006145 11520622640 033066 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class TimestampTestCase : DrsTestCase { public virtual void Test() { ITestableReplicationProviderInside providerA = A().Provider(); ITestableReplicationProviderInside providerB = B().Provider(); providerA.StoreNew(new Pilot()); providerA.Commit(); IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures .reflector); TimeStamps initialTimeStampsB = AssertTimeStampsForFirstReplication(providerB); IObjectSet modifiedObjects = providerA.ObjectsChangedSinceLastReplication(); while (modifiedObjects.HasNext()) { replication.Replicate(modifiedObjects.Next()); } replication.Commit(); Pilot replicatedPilot = (Pilot)providerB.GetStoredObjects(typeof(Pilot)).Next(); long version = providerB.ObjectVersion(replicatedPilot); Assert.AreEqual(initialTimeStampsB.Commit(), version); replication = Replication.Begin(providerA, providerB, null, _fixtures.reflector); TimeStamps timestampsBAfterReplication = AssertTimeStampsForSecondReplication(initialTimeStampsB , providerB); replication.Commit(); Pilot pilotStoredAfterReplication = new Pilot(); providerB.StoreNew(pilotStoredAfterReplication); providerB.Commit(); providerB.WaitForPreviousCommits(); version = providerB.ObjectVersion(pilotStoredAfterReplication); Assert.IsGreater(timestampsBAfterReplication.Commit(), version); } private TimeStamps AssertTimeStampsForFirstReplication(ITestableReplicationProviderInside provider) { TimeStamps timeStamps = provider.TimeStamps(); Assert.IsNotNull(timeStamps); Assert.AreEqual(0, timeStamps.From()); Assert.IsGreater(0, timeStamps.To()); Assert.AreEqual(timeStamps.To() + 1, timeStamps.Commit()); return timeStamps; } private TimeStamps AssertTimeStampsForSecondReplication(TimeStamps initialTimeStamps , ITestableReplicationProviderInside provider) { TimeStamps timeStamps = provider.TimeStamps(); Assert.IsNotNull(timeStamps); Assert.AreEqual(initialTimeStamps.Commit(), timeStamps.From()); Assert.IsGreater(timeStamps.From(), timeStamps.To()); Assert.AreEqual(timeStamps.To() + 1, timeStamps.Commit()); return timeStamps; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ArrayReplicationTest.cs000644 001750 001750 00000005754 11520622636 033611 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ArrayReplicationTest : DrsTestCase { public virtual void Test() { if (!A().Provider().SupportsMultiDimensionalArrays()) { return; } if (!B().Provider().SupportsMultiDimensionalArrays()) { return; } ArrayHolder h1 = new ArrayHolder("h1"); ArrayHolder h2 = new ArrayHolder("h2"); h1._array = new ArrayHolder[] { h1 }; h2._array = new ArrayHolder[] { h1, h2, null }; h1._arrayN = new ArrayHolder[][] { new ArrayHolder[] { h1 } }; h2._arrayN = new ArrayHolder[][] { new ArrayHolder[] { h1, null }, new ArrayHolder [] { null, h2 }, new ArrayHolder[] { null, null } }; //TODO Fix ReflectArray.shape() and test with innermost arrays of varying sizes: {{h1}, {null, h2}, {null}} B().Provider().StoreNew(h2); B().Provider().StoreNew(h1); B().Provider().Commit(); IReplicationSession replication = new GenericReplicationSession(A().Provider(), B ().Provider(), null, _fixtures.reflector); replication.Replicate(h2); //Traverses to h1. replication.Commit(); IEnumerator objects = A().Provider().GetStoredObjects(typeof(ArrayHolder)).GetEnumerator (); CheckNext(objects); CheckNext(objects); Assert.IsFalse(objects.MoveNext()); } private void CheckNext(IEnumerator objects) { Assert.IsTrue(objects.MoveNext()); Check((ArrayHolder)objects.Current); } private void Check(ArrayHolder holder) { if (holder.GetName().Equals("h1")) { CheckH1(holder); } else { CheckH2(holder); } } protected virtual void CheckH1(ArrayHolder holder) { Assert.AreEqual(holder.Array()[0], holder); Assert.AreEqual(holder.ArrayN()[0][0], holder); } protected virtual void CheckH2(ArrayHolder holder) { Assert.AreEqual(holder.Array()[0].GetName(), "h1"); Assert.AreEqual(holder.Array()[1], holder); Assert.AreEqual(holder.Array()[2], null); Assert.AreEqual(holder.ArrayN()[0][0].GetName(), "h1"); Assert.AreEqual(holder.ArrayN()[1][0], null); Assert.AreEqual(holder.ArrayN()[1][1], holder); Assert.AreEqual(holder.ArrayN()[2][0], null); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/SimpleParentChild.cs000644 001750 001750 00000006245 11520622640 033037 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class SimpleParentChild : DrsTestCase { public virtual void Test() { StoreParentAndChildToProviderA(); ReplicateAllToProviderBFirstTime(); ModifyParentInProviderB(); ReplicateAllStep2(); ModifyParentAndChildInProviderA(); ReplicateParentClassStep3(); } private void EnsureNames(IDrsProviderFixture fixture, string parentName, string childName ) { EnsureOneInstanceOfParentAndChild(fixture); SPCParent parent = (SPCParent)GetOneInstance(fixture, typeof(SPCParent)); if (!parent.GetName().Equals(parentName)) { Sharpen.Runtime.Out.WriteLine("expected = " + parentName); Sharpen.Runtime.Out.WriteLine("actual = " + parent.GetName()); } Assert.AreEqual(parentName, parent.GetName()); Assert.AreEqual(childName, parent.GetChild().GetName()); } private void EnsureOneInstanceOfParentAndChild(IDrsProviderFixture fixture) { EnsureOneInstance(fixture, typeof(SPCParent)); EnsureOneInstance(fixture, typeof(SPCChild)); } private void ModifyParentAndChildInProviderA() { SPCParent parent = (SPCParent)GetOneInstance(A(), typeof(SPCParent)); parent.SetName("p3"); SPCChild child = parent.GetChild(); child.SetName("c3"); A().Provider().Update(parent); A().Provider().Update(child); A().Provider().Commit(); EnsureNames(A(), "p3", "c3"); } private void ModifyParentInProviderB() { SPCParent parent = (SPCParent)GetOneInstance(B(), typeof(SPCParent)); parent.SetName("p2"); B().Provider().Update(parent); B().Provider().Commit(); EnsureNames(B(), "p2", "c1"); } private void ReplicateAllStep2() { ReplicateAll(B().Provider(), A().Provider()); EnsureNames(A(), "p2", "c1"); EnsureNames(B(), "p2", "c1"); } private void ReplicateAllToProviderBFirstTime() { ReplicateAll(A().Provider(), B().Provider()); EnsureNames(A(), "p1", "c1"); EnsureNames(B(), "p1", "c1"); } private void ReplicateParentClassStep3() { ReplicateClass(A().Provider(), B().Provider(), typeof(SPCParent)); EnsureNames(A(), "p3", "c3"); EnsureNames(B(), "p3", "c3"); } private void StoreParentAndChildToProviderA() { SPCChild child = new SPCChild("c1"); SPCParent parent = new SPCParent(child, "p1"); A().Provider().StoreNew(parent); A().Provider().Commit(); EnsureNames(A(), "p1", "c1"); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/DrsFixtureVariable.cs000644 001750 001750 00000002165 11520622636 033237 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class DrsFixtureVariable { private static readonly FixtureVariable _variable = new FixtureVariable("drs"); public static DrsFixture Value() { return (DrsFixture)_variable.Value; } public static object With(DrsFixture pair, IClosure4 closure) { return _variable.With(pair, closure); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/DrsTestSuiteBuilder.cs000644 001750 001750 00000004202 11520622636 033375 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Tests; using Sharpen; namespace Db4objects.Drs.Tests { public class DrsTestSuiteBuilder : ReflectionTestSuiteBuilder { private DrsFixture _fixtures; public DrsTestSuiteBuilder(IDrsProviderFixture a, IDrsProviderFixture b, Type clazz ) : this(a, b, new Type[] { clazz }, null) { } public DrsTestSuiteBuilder(IDrsProviderFixture a, IDrsProviderFixture b, Type clazz , IReflector reflector) : this(a, b, new Type[] { clazz }, reflector) { } public DrsTestSuiteBuilder(IDrsProviderFixture a, IDrsProviderFixture b, Type[] classes , IReflector reflector) : base(AppendDestructor(classes)) { _fixtures = new DrsFixture(a, b, reflector); } private static Type[] AppendDestructor(Type[] classes) { Type[] newClasses = new Type[classes.Length + 1]; System.Array.Copy(classes, 0, newClasses, 0, classes.Length); newClasses[newClasses.Length - 1] = typeof(DrsTestSuiteBuilder.DrsFixtureDestructor ); return newClasses; } public class DrsFixtureDestructor : ITestCase { public virtual void TestFixtureDestruction() { DrsFixture fixturePair = DrsFixtureVariable.Value(); fixturePair.a.Destroy(); fixturePair.b.Destroy(); } } protected override object WithContext(IClosure4 closure) { return DrsFixtureVariable.With(_fixtures, closure); } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/EqualsHashCodeOverriddenTestCaseBase.cs000644 001750 001750 00000005433 11520622636 036516 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.IO; using Db4objects.Drs; using Db4objects.Drs.Db4o; using Db4objects.Drs.Tests; namespace Db4objects.Drs.Tests { public class EqualsHashCodeOverriddenTestCaseBase : ITestCase { public class Item { public string _name; public Item(string name) { _name = name; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj == null || GetType() != obj.GetType()) { return false; } return _name.Equals(((EqualsHashCodeOverriddenTestCaseBase.Item)obj)._name); } public override int GetHashCode() { return _name.GetHashCode(); } } private IStorage _storage = new MemoryStorage(); public EqualsHashCodeOverriddenTestCaseBase() : base() { } protected virtual void AssertReplicates(object holder) { IEmbeddedObjectContainer sourceDb = OpenContainer("source"); sourceDb.Store(holder); sourceDb.Commit(); IEmbeddedObjectContainer targetDb = OpenContainer("target"); try { Db4oEmbeddedReplicationProvider providerA = new Db4oEmbeddedReplicationProvider(sourceDb ); Db4oEmbeddedReplicationProvider providerB = new Db4oEmbeddedReplicationProvider(targetDb ); IReplicationSession replication = Replication.Begin(providerA, providerB); IObjectSet changed = replication.ProviderA().ObjectsChangedSinceLastReplication(); while (changed.HasNext()) { object o = changed.Next(); if (holder.GetType() == o.GetType()) { replication.Replicate(o); break; } } replication.Commit(); } finally { sourceDb.Close(); targetDb.Close(); } } private IEmbeddedObjectContainer OpenContainer(string filePath) { IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration(); config.File.Storage = _storage; config.File.GenerateUUIDs = ConfigScope.Globally; config.File.GenerateCommitTimestamps = true; return Db4oEmbedded.OpenFile(config, filePath); } } } src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/TheSimplestWithCallConstructors.cs000644 001750 001750 00000002135 11520622640 035725 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Config; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class TheSimplestWithCallConstructors : TheSimplest { protected override void Configure(IConfiguration config) { config.CallConstructors(true); } protected override SPCChild CreateChildObject(string name) { return new SPCChildWithoutDefaultConstructor(name); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/ReplicationProviderTest.cs000644 001750 001750 00000024401 11520622640 034306 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Db4o.Ext; using Db4objects.Drs.Foundation; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class ReplicationProviderTest : DrsTestCase { protected byte[] BSignatureBytes; protected IReadonlyReplicationProviderSignature BSignature; private IReadonlyReplicationProviderSignature ASignature; public virtual void TestReplicationLifeCycle() { BSignatureBytes = B().Provider().GetSignature().GetSignature(); ASignature = A().Provider().GetSignature(); BSignature = B().Provider().GetSignature(); TstObjectUpdate(); TstSignature(); TstObjectsChangedSinceLastReplication(); TstReferences(); TstStore(); TstRollback(); TstDeletion(); } protected virtual void TstDeletion() { A().Provider().StoreNew(new Pilot("Pilot1", 42)); Pilot o = new Pilot("Pilot2", 43); A().Provider().StoreNew(o); A().Provider().Commit(); A().Provider().StoreNew(new Pilot("Pilot3", 44)); A().Provider().Delete(FindPilot("Pilot1")); Car car = new Car("Car1"); car.SetPilot(FindPilot("Pilot2")); A().Provider().StoreNew(car); A().Provider().Commit(); StartReplication(); IDrsUUID uuidCar1 = Uuid(FindCar("Car1")); Assert.IsNotNull(uuidCar1); A().Provider().ReplicateDeletion(uuidCar1); CommitReplication(); Assert.IsNull(FindCar("Car1")); StartReplication(); IDrsUUID uuidPilot2 = Uuid(FindPilot("Pilot2")); Assert.IsNotNull(uuidPilot2); A().Provider().ReplicateDeletion(uuidPilot2); CommitReplication(); Assert.IsNull(FindPilot("Pilot2")); } private void CommitReplication() { A().Provider().CommitReplicationTransaction(); B().Provider().CommitReplicationTransaction(); } private object FindCar(string model) { IEnumerator cars = A().Provider().GetStoredObjects(typeof(Car)).GetEnumerator(); while (cars.MoveNext()) { Car candidate = (Car)cars.Current; if (candidate.GetModel().Equals(model)) { return candidate; } } return null; } private Pilot FindPilot(string name) { IEnumerator pilots = A().Provider().GetStoredObjects(typeof(Pilot)).GetEnumerator (); while (pilots.MoveNext()) { Pilot candidate = (Pilot)pilots.Current; if (candidate.Name().Equals(name)) { return candidate; } } return null; } private SPCChild GetOneChildFromA() { return GetOneChild(A()); } private SPCChild GetOneChild(IDrsProviderFixture fixture) { IObjectSet storedObjects = fixture.Provider().GetStoredObjects(typeof(SPCChild)); Assert.AreEqual(1, storedObjects.Count); IEnumerator iterator = storedObjects.GetEnumerator(); Assert.IsTrue(iterator.MoveNext()); return (SPCChild)iterator.Current; } private void StartReplication() { A().Provider().StartReplicationTransaction(BSignature); B().Provider().StartReplicationTransaction(ASignature); } private void TstObjectUpdate() { SPCChild child = new SPCChild("c1"); A().Provider().StoreNew(child); A().Provider().Commit(); StartReplication(); SPCChild reloaded = GetOneChildFromA(); long oldVer = A().Provider().ProduceReference(reloaded, null, null).Version(); CommitReplication(); SPCChild reloaded2 = GetOneChildFromA(); reloaded2.SetName("c3"); //System.out.println("==============BEGIN DEBUG"); A().Provider().Update(reloaded2); A().Provider().Commit(); //System.out.println("==============END DEBUG"); StartReplication(); SPCChild reloaded3 = GetOneChildFromA(); long newVer = A().Provider().ProduceReference(reloaded3, null, null).Version(); CommitReplication(); Assert.IsGreater(oldVer, newVer); } private void TstObjectsChangedSinceLastReplication() { Pilot object1 = new Pilot("John Cleese", 42); Pilot object2 = new Pilot("Terry Gilliam", 53); Car object3 = new Car("Volvo"); A().Provider().StoreNew(object1); A().Provider().StoreNew(object2); A().Provider().StoreNew(object3); A().Provider().Commit(); StartReplication(); IObjectSet changed = A().Provider().ObjectsChangedSinceLastReplication(); Assert.AreEqual(3, changed.Count); IObjectSet os = A().Provider().ObjectsChangedSinceLastReplication(typeof(Pilot)); Assert.AreEqual(2, os.Count); IEnumerator pilots = os.GetEnumerator(); // Assert.isTrue(pilots.contains(findPilot("John Cleese"))); // Assert.isTrue(pilots.contains(findPilot("Terry Gilliam"))); IEnumerator cars = A().Provider().ObjectsChangedSinceLastReplication(typeof(Car)) .GetEnumerator(); Assert.AreEqual("Volvo", ((Car)Next(cars)).GetModel()); Assert.IsFalse(cars.MoveNext()); CommitReplication(); StartReplication(); Assert.IsFalse(A().Provider().ObjectsChangedSinceLastReplication().GetEnumerator( ).MoveNext()); CommitReplication(); Pilot pilot = (Pilot)Next(A().Provider().GetStoredObjects(typeof(Pilot)).GetEnumerator ()); pilot.SetName("Terry Jones"); Car car = (Car)Next(A().Provider().GetStoredObjects(typeof(Car)).GetEnumerator()); car.SetModel("McLaren"); A().Provider().Update(pilot); A().Provider().Update(car); A().Provider().Commit(); StartReplication(); Assert.AreEqual(2, A().Provider().ObjectsChangedSinceLastReplication().Count); pilots = A().Provider().ObjectsChangedSinceLastReplication(typeof(Pilot)).GetEnumerator (); Assert.AreEqual("Terry Jones", ((Pilot)Next(pilots)).Name()); Assert.IsFalse(pilots.MoveNext()); cars = A().Provider().ObjectsChangedSinceLastReplication(typeof(Car)).GetEnumerator (); Assert.AreEqual("McLaren", ((Car)Next(cars)).GetModel()); Assert.IsFalse(cars.MoveNext()); CommitReplication(); A().Provider().DeleteAllInstances(typeof(Pilot)); A().Provider().DeleteAllInstances(typeof(Car)); A().Provider().Commit(); } private object Next(IEnumerator iterator) { Assert.IsTrue(iterator.MoveNext()); return iterator.Current; } private void TstReferences() { Pilot pilot = new Pilot("tst References", 42); A().Provider().StoreNew(pilot); A().Provider().Commit(); StartReplication(); Pilot object1 = (Pilot)Next(A().Provider().GetStoredObjects(typeof(Pilot)).GetEnumerator ()); IReplicationReference reference = A().Provider().ProduceReference(object1, null, null); Assert.AreEqual(object1, reference.Object()); IDrsUUID uuid = reference.Uuid(); IReplicationReference ref2 = A().Provider().ProduceReferenceByUUID(uuid, typeof(Pilot )); Assert.AreEqual(reference, ref2); A().Provider().ClearAllReferences(); IDrsUUID db4oUUID = A().Provider().ProduceReference(object1, null, null).Uuid(); Assert.AreEqual(uuid, db4oUUID); CommitReplication(); A().Provider().DeleteAllInstances(typeof(Pilot)); A().Provider().Commit(); } private void TstRollback() { if (!A().Provider().SupportsRollback()) { return; } if (!B().Provider().SupportsRollback()) { return; } StartReplication(); Pilot object1 = new Pilot("Albert Kwan", 25); IDrsUUID uuid = new DrsUUIDImpl(new Db4oUUID(5678, BSignatureBytes)); IReplicationReference @ref = new ReplicationReferenceImpl(object1, uuid, 1); A().Provider().ReferenceNewObject(object1, @ref, null, null); A().Provider().StoreReplica(object1); Assert.IsFalse(A().Provider().WasModifiedSinceLastReplication(@ref)); A().Provider().RollbackReplication(); A().Provider().StartReplicationTransaction(BSignature); Assert.IsNull(A().Provider().ProduceReference(object1, null, null)); IReplicationReference byUUID = A().Provider().ProduceReferenceByUUID(uuid, object1 .GetType()); Assert.IsNull(byUUID); A().Provider().RollbackReplication(); B().Provider().RollbackReplication(); } private void TstSignature() { Assert.IsNotNull(A().Provider().GetSignature()); } private void TstStore() { StartReplication(); Pilot object1 = new Pilot("John Cleese", 42); IDrsUUID uuid = new DrsUUIDImpl(new Db4oUUID(15, BSignatureBytes)); IReplicationReference @ref = new ReplicationReferenceImpl("ignoredSinceInOtherProvider" , uuid, 1); A().Provider().ReferenceNewObject(object1, @ref, null, null); A().Provider().StoreReplica(object1); IReplicationReference reference = A().Provider().ProduceReferenceByUUID(uuid, object1 .GetType()); Assert.AreEqual(reference, A().Provider().ProduceReference(object1, null, null)); Assert.AreEqual(object1, reference.Object()); CommitReplication(); StartReplication(); IEnumerator storedObjects = A().Provider().GetStoredObjects(typeof(Pilot)).GetEnumerator (); Pilot reloaded = (Pilot)Next(storedObjects); Assert.IsFalse(storedObjects.MoveNext()); reference = A().Provider().ProduceReferenceByUUID(uuid, object1.GetType()); Assert.AreEqual(reference, A().Provider().ProduceReference(reloaded, null, null)); reloaded.SetName("i am updated"); A().Provider().StoreReplica(reloaded); A().Provider().ClearAllReferences(); CommitReplication(); StartReplication(); reference = A().Provider().ProduceReferenceByUUID(uuid, reloaded.GetType()); Assert.AreEqual("i am updated", ((Pilot)reference.Object()).Name()); CommitReplication(); A().Provider().DeleteAllInstances(typeof(Pilot)); A().Provider().Commit(); } private IDrsUUID Uuid(object obj) { return A().Provider().ProduceReference(obj, null, null).Uuid(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Dotnet/000755 001750 001750 00000000000 11520622062 030365 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Dotnet/StructTestCase.cs000644 001750 001750 00000003710 11520622636 033644 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Dotnet { public class StructTestCase : DrsTestCase { internal Container template = new Container(new Value(42)); public virtual void Test() { StoreToProviderA(); ReplicateAllToProviderB(); } internal virtual void StoreToProviderA() { ITestableReplicationProviderInside provider = A().Provider(); provider.StoreNew(template); provider.Commit(); EnsureContent(template, provider); } internal virtual void ReplicateAllToProviderB() { ReplicateAll(A().Provider(), B().Provider()); EnsureContent(template, B().Provider()); } private void EnsureContent(Container container, ITestableReplicationProviderInside provider) { IObjectSet result = provider.GetStoredObjects(container.GetType()); Assert.AreEqual(1, result.Count); Container c = Next(result); Assert.AreEqual(template.GetValue(), c.GetValue()); } private Container Next(IObjectSet result) { IEnumerator iterator = result.GetEnumerator(); if (iterator.MoveNext()) { return (Container)iterator.Current; } return null; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/DrsTestCase.cs000644 001750 001750 00000016107 11520622636 031657 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Drs; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; using Sharpen.Lang; namespace Db4objects.Drs.Tests { public abstract class DrsTestCase : ITestCase, ITestLifeCycle { public static readonly Type[] mappings; public static readonly Type[] extraMappingsForCleaning = new Type[] { typeof(IList ), typeof(IDictionary) }; static DrsTestCase() { mappings = new Type[] { typeof(Car), typeof(CollectionHolder), typeof(ListContent ), typeof(ListHolder), typeof(MapContent), typeof(Pilot), typeof(R0), typeof(Replicated ), typeof(SimpleArrayContent), typeof(SimpleArrayHolder), typeof(SimpleItem), typeof( SimpleListHolder), typeof(SPCChild), typeof(SPCParent), typeof(ItemWithUntypedField ), typeof(ItemDates), typeof(NamedList), typeof(ItemWithCloneable) }; } protected readonly DrsFixture _fixtures = DrsFixtureVariable.Value(); private Db4objects.Drs.Inside.ReplicationReflector _reflector; /// public virtual void SetUp() { CleanBoth(); ConfigureBoth(); OpenBoth(); Store(); Reopen(); } private void CleanBoth() { A().Clean(); B().Clean(); } protected virtual void Clean() { for (int i = 0; i < mappings.Length; i++) { A().Provider().DeleteAllInstances(mappings[i]); B().Provider().DeleteAllInstances(mappings[i]); } for (int i = 0; i < extraMappingsForCleaning.Length; i++) { A().Provider().DeleteAllInstances(extraMappingsForCleaning[i]); B().Provider().DeleteAllInstances(extraMappingsForCleaning[i]); } A().Provider().Commit(); B().Provider().Commit(); } protected virtual void Store() { } private void ConfigureBoth() { ConfigureInitial(_fixtures.a); ConfigureInitial(_fixtures.b); } private void ConfigureInitial(IDrsProviderFixture fixture) { IConfiguration config = Db4oConfiguration(fixture); if (config == null) { return; } config.GenerateUUIDs(ConfigScope.Globally); config.GenerateCommitTimestamps(true); Configure(config); } private IConfiguration Db4oConfiguration(IDrsProviderFixture fixture) { if (!(fixture is Db4oDrsFixture)) { return null; } return ((Db4oDrsFixture)fixture).Config(); } protected virtual void Configure(IConfiguration config) { } /// protected virtual void Reopen() { CloseBoth(); OpenBoth(); } /// private void OpenBoth() { A().Open(); B().Open(); _reflector = new Db4objects.Drs.Inside.ReplicationReflector(A().Provider(), B().Provider (), _fixtures.reflector); A().Provider().ReplicationReflector(_reflector); B().Provider().ReplicationReflector(_reflector); } /// public virtual void TearDown() { CloseBoth(); CleanBoth(); } /// private void CloseBoth() { A().Close(); B().Close(); } public virtual IDrsProviderFixture A() { return _fixtures.a; } public virtual IDrsProviderFixture B() { return _fixtures.b; } protected virtual void EnsureOneInstance(IDrsProviderFixture fixture, Type clazz) { EnsureInstanceCount(fixture, clazz, 1); } protected virtual void EnsureInstanceCount(IDrsProviderFixture fixture, Type clazz , int count) { IObjectSet objectSet = fixture.Provider().GetStoredObjects(clazz); Assert.AreEqual(count, objectSet.Count); } protected virtual object GetOneInstance(IDrsProviderFixture fixture, Type clazz) { IEnumerator objectSet = fixture.Provider().GetStoredObjects(clazz).GetEnumerator( ); object candidate = null; if (objectSet.MoveNext()) { candidate = objectSet.Current; if (objectSet.MoveNext()) { throw new Exception("Found more than one instance of + " + clazz + " in provider = " + fixture); } } return candidate; } protected virtual void ReplicateAll(ITestableReplicationProviderInside providerFrom , ITestableReplicationProviderInside providerTo) { IReplicationSession replication = Replication.Begin(providerFrom, providerTo, _fixtures .reflector); IObjectSet changedSet = providerFrom.ObjectsChangedSinceLastReplication(); if (changedSet.Count == 0) { throw new Exception("Can't find any objects to replicate"); } ReplicateAll(replication, changedSet.GetEnumerator()); } protected virtual void ReplicateAll(IReplicationSession replication, IEnumerator allObjects) { while (allObjects.MoveNext()) { object changed = allObjects.Current; // System.out.println("Replicating = " + changed); replication.Replicate(changed); } replication.Commit(); } protected virtual void ReplicateAll(ITestableReplicationProviderInside from, ITestableReplicationProviderInside to, IReplicationEventListener listener) { IReplicationSession replication = Replication.Begin(from, to, listener, _fixtures .reflector); ReplicateAll(replication, from.ObjectsChangedSinceLastReplication().GetEnumerator ()); } protected virtual void Delete(Type[] classes) { for (int i = 0; i < classes.Length; i++) { A().Provider().DeleteAllInstances(classes[i]); B().Provider().DeleteAllInstances(classes[i]); } A().Provider().Commit(); B().Provider().Commit(); } protected virtual void ReplicateClass(ITestableReplicationProviderInside providerA , ITestableReplicationProviderInside providerB, Type clazz) { IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures .reflector); IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator (); ReplicateAll(replication, allObjects); } protected static void Sleep(int millis) { try { Thread.Sleep(millis); } catch (Exception e) { throw new Exception(e.ToString()); } } protected virtual Db4objects.Drs.Inside.ReplicationReflector ReplicationReflector () { return _reflector; } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/DateReplicationTestCase.cs000644 001750 001750 00000002722 11520622636 034174 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; using Sharpen; namespace Db4objects.Drs.Tests { public class DateReplicationTestCase : DrsTestCase { public virtual void Test() { ItemDates item1 = new ItemDates(new DateTime(0), new DateTime()); ItemDates item2 = new ItemDates(new DateTime(10000), new DateTime(Runtime.CurrentTimeMillis () - 10000)); A().Provider().StoreNew(item1); A().Provider().StoreNew(item2); A().Provider().Commit(); ReplicateAll(A().Provider(), B().Provider()); IObjectSet found = B().Provider().GetStoredObjects(typeof(ItemDates)); Iterator4Assert.SameContent(new object[] { item2, item1 }, ReplicationTestPlatform .Adapt(found.GetEnumerator())); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Db4oDrsFixture.cs000644 001750 001750 00000006456 11520622636 032311 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Reflect; using Db4objects.Drs.Db4o; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Sharpen; using Sharpen.IO; namespace Db4objects.Drs.Tests { public class Db4oDrsFixture : IDrsProviderFixture { protected string _name; protected IExtObjectContainer _db; protected ITestableReplicationProviderInside _provider; protected readonly File testFile; private IConfiguration _config; internal static readonly string RamDriveProperty = "db4o.drs.path"; private static readonly string Path; static Db4oDrsFixture() { // TODO: No need to maintain the database here. It can be in the provider. string path = Runtime.GetProperty(RamDriveProperty); if (path == null) { path = Runtime.Getenv(RamDriveProperty); } if (path == null || path.Length == 0) { Sharpen.Runtime.Out.WriteLine("You can tune dRS tests by setting the environment variable " ); Sharpen.Runtime.Out.WriteLine(RamDriveProperty); Sharpen.Runtime.Out.WriteLine("to your RAM drive."); path = "."; } Path = path; } public Db4oDrsFixture(string name) : this(name, null) { } public Db4oDrsFixture(string name, IReflector reflector) { _name = name; File folder = new File(Path); if (!folder.Exists()) { Sharpen.Runtime.Out.WriteLine("Path " + Path + " does not exist. Using current working folder." ); Sharpen.Runtime.Out.WriteLine("Check the " + RamDriveProperty + " environment variable on your system." ); folder = new File("."); } testFile = new File(folder.GetPath() + "/drs_cs_" + _name + ".db4o"); if (reflector != null) { Config().ReflectWith(reflector); } } public virtual ITestableReplicationProviderInside Provider() { return _provider; } public virtual void Clean() { testFile.Delete(); _config = null; } public virtual void Close() { _provider.Destroy(); _db.Close(); _provider = null; } public virtual void Open() { _db = Db4oFactory.OpenFile(CloneConfiguration(), testFile.GetPath()).Ext(); _provider = Db4oProviderFactory.NewInstance(_db, _name); } private IConfiguration CloneConfiguration() { return (IConfiguration)((IDeepClone)Config()).DeepClone(null); } public virtual IConfiguration Config() { if (_config == null) { _config = Db4oFactory.NewConfiguration(); } return _config; } public virtual void Destroy() { } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/MapTest.cs000644 001750 001750 00000011017 11520622640 031036 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests { public class MapTest : DrsTestCase { protected virtual void ActualTest() { StoreMapToProviderA(); ReplicateAllToProviderBFirstTime(); ModifyInProviderB(); ReplicateAllStep2(); AddElementInProviderA(); ReplicateHolderStep3(); } private void StoreMapToProviderA() { MapHolder mh = new MapHolder("h1"); MapContent mc1 = new MapContent("c1"); MapContent mc2 = new MapContent("c2"); mh.Put("key1", mc1); mh.Put("key2", mc2); A().Provider().StoreNew(mh); A().Provider().Commit(); EnsureContent(A(), new string[] { "h1" }, new string[] { "key1", "key2" }, new string [] { "c1", "c2" }); } private void ReplicateAllToProviderBFirstTime() { ReplicateAll(A().Provider(), B().Provider()); EnsureContent(A(), new string[] { "h1" }, new string[] { "key1", "key2" }, new string [] { "c1", "c2" }); EnsureContent(B(), new string[] { "h1" }, new string[] { "key1", "key2" }, new string [] { "c1", "c2" }); } private void ModifyInProviderB() { MapHolder mh = (MapHolder)GetOneInstance(B(), typeof(MapHolder)); mh.SetName("h2"); MapContent mc1 = (MapContent)mh.GetMap()["key1"]; MapContent mc2 = (MapContent)mh.GetMap()["key2"]; mc1.SetName("co1"); mc2.SetName("co2"); B().Provider().Update(mc1); B().Provider().Update(mc2); B().Provider().Update(mh.GetMap()); B().Provider().Update(mh); B().Provider().Commit(); EnsureContent(B(), new string[] { "h2" }, new string[] { "key1", "key2" }, new string [] { "co1", "co2" }); } private void ReplicateAllStep2() { ReplicateAll(B().Provider(), A().Provider()); EnsureContent(A(), new string[] { "h2" }, new string[] { "key1", "key2" }, new string [] { "co1", "co2" }); EnsureContent(B(), new string[] { "h2" }, new string[] { "key1", "key2" }, new string [] { "co1", "co2" }); } private void AddElementInProviderA() { MapHolder mh = (MapHolder)GetOneInstance(A(), typeof(MapHolder)); mh.SetName("h3"); MapContent mc3 = new MapContent("co3"); A().Provider().StoreNew(mc3); mh.GetMap()["key3"] = mc3; A().Provider().Update(mh.GetMap()); A().Provider().Update(mh); A().Provider().Commit(); EnsureContent(A(), new string[] { "h3" }, new string[] { "key1", "key2", "key3" } , new string[] { "co1", "co2", "co3" }); } private void ReplicateHolderStep3() { ReplicateClass(A().Provider(), B().Provider(), typeof(MapHolder)); EnsureContent(A(), new string[] { "h3" }, new string[] { "key1", "key2", "key3" } , new string[] { "co1", "co2", "co3" }); EnsureContent(B(), new string[] { "h3" }, new string[] { "key1", "key2", "key3" } , new string[] { "co1", "co2", "co3" }); } private void EnsureContent(IDrsProviderFixture fixture, string[] holderNames, string [] keyNames, string[] valueNames) { int holderCount = holderNames.Length; EnsureInstanceCount(fixture, typeof(MapHolder), holderCount); // After dropping generating uuid for collection, it does not // make sense to count collection because collection is never reused // ensureInstanceCount(provider, Map.class, holderCount); int i = 0; IEnumerator objectSet = fixture.Provider().GetStoredObjects(typeof(MapHolder)).GetEnumerator (); while (objectSet.MoveNext()) { MapHolder lh = (MapHolder)objectSet.Current; Assert.AreEqual(holderNames[i], lh.GetName()); IDictionary Map = lh.GetMap(); for (int j = 0; j < keyNames.Length; j++) { MapContent mc = (MapContent)Map[keyNames[j]]; string name = mc.GetName(); Assert.AreEqual(valueNames[j], name); } } } public virtual void Test() { ActualTest(); } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Regression/000755 001750 001750 00000000000 11520622070 031247 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Db4objects.Drs.Tests/Regression/DRS42Test.cs000644 001750 001750 00000004062 11520622640 033241 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4objects.Db4o; using Db4objects.Drs.Inside; using Db4objects.Drs.Tests; using Db4objects.Drs.Tests.Data; namespace Db4objects.Drs.Tests.Regression { public class DRS42Test : DrsTestCase { internal NewPilot andrew = new NewPilot("Andrew", 100, new int[] { 100, 200, 300 } ); public virtual void Test() { StoreToProviderA(); ReplicateAllToProviderB(); } internal virtual void StoreToProviderA() { ITestableReplicationProviderInside provider = A().Provider(); provider.StoreNew(andrew); provider.Commit(); EnsureContent(andrew, provider); } internal virtual void ReplicateAllToProviderB() { ReplicateAll(A().Provider(), B().Provider()); EnsureContent(andrew, B().Provider()); } private void EnsureContent(NewPilot newPilot, ITestableReplicationProviderInside provider) { IObjectSet objectSet = provider.GetStoredObjects(typeof(NewPilot)); Assert.AreEqual(1, objectSet.Count); IEnumerator iterator = objectSet.GetEnumerator(); Assert.IsTrue(iterator.MoveNext()); NewPilot p = (NewPilot)iterator.Current; Assert.AreEqual(newPilot.GetName(), p.GetName()); Assert.AreEqual(newPilot.GetPoints(), p.GetPoints()); for (int j = 0; j < newPilot.GetArr().Length; j++) { Assert.AreEqual(newPilot.GetArr()[j], p.GetArr()[j]); } } } } db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Properties/000755 001750 001750 00000000000 11520622040 025445 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/drs/Db4objects.Drs.Tests/Properties/AssemblyInfo.cs000644 001750 001750 00000002420 11520622640 030373 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Db4objects.Drs.Tests")] [assembly: AssemblyDescription("Db4objects.Drs.Tests 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: AssemblyVersion("8.0.184.15484")] db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/000755 001750 001750 00000000000 11520622064 022502 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions-2010.csproj000644 001750 001750 00000030020 11520622042 030061 0ustar00directhexdirecthex000000 000000 9.0.30729 2.0 Debug AnyCPU Db4oUnit.Extensions Library Db4oUnit.Extensions OnBuildSuccess v4.0 512 {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3} 3.5 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../db4objects.snk bin\Debug\ false 285212672 false true TRACE;DEBUG;NET_3_5;NET_4_0 4096 false 1591;1572;1573;1574;0419; false false false false 0 bin\Release\ false 285212672 false false TRACE;NET_3_5;NET_4_0 4096 false 1591;1572;1573;1574;0419; true false false false 4 System False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {9FA8178A-3E77-42C5-A252-6690EA9BA257} Db4objects.Db4o.CS-2010 {E9588FE7-C19D-445E-BB53-AE539EA4F0E6} Db4objects.Db4o.Optional-2010 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2010 {8F82F8B0-95B6-4553-BDA8-BD9A954E682F} Db4oUnit-2010 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/000755 001750 001750 00000000000 11520622070 026265 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutAndroid.cs000644 001750 001750 00000001366 11520622622 031471 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Extensions { public interface IOptOutAndroid { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/AbstractInMemoryDb4oTestCase.cs000644 001750 001750 00000002120 11520622622 034202 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o.Config; using Db4objects.Db4o.IO; namespace Db4oUnit.Extensions { public class AbstractInMemoryDb4oTestCase : AbstractDb4oTestCase, IOptOutMultiSession { /// protected override void Configure(IConfiguration config) { config.Storage = new MemoryStorage(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IFixtureConfiguration.cs000644 001750 001750 00000001624 11520622622 033111 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions { public interface IFixtureConfiguration { string GetLabel(); void Configure(IDb4oTestCase testCase, IConfiguration config); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ExcludingReflector.cs000644 001750 001750 00000004333 11520622622 032412 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Reflect; namespace Db4oUnit.Extensions { public class ExcludingReflector : Db4objects.Db4o.Reflect.Net.NetReflector { private readonly Collection4 _excludedClasses; public ExcludingReflector(Type[] excludedClasses) { _excludedClasses = new Collection4(); for (int claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex) { Type claxx = excludedClasses[claxxIndex]; _excludedClasses.Add(claxx.FullName); } } public ExcludingReflector(ByRef loaderClass, Type[] excludedClasses) { _excludedClasses = new Collection4(); for (int claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex) { Type claxx = excludedClasses[claxxIndex]; _excludedClasses.Add(claxx.FullName); } } public ExcludingReflector(Collection4 excludedClasses) { _excludedClasses = excludedClasses; } public ExcludingReflector(ByRef loaderClass, Collection4 excludedClasses) { _excludedClasses = excludedClasses; } public override object DeepClone(object obj) { return new Db4oUnit.Extensions.ExcludingReflector(_excludedClasses); } public override IReflectClass ForName(string className) { if (_excludedClasses.Contains(className)) { return null; } return base.ForName(className); } public override IReflectClass ForClass(Type clazz) { if (_excludedClasses.Contains(clazz.FullName)) { return null; } return base.ForClass(clazz); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/000755 001750 001750 00000000000 11520622070 027367 5ustar00directhexdirecthex000000 000000 src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/UnhandledExceptionInThreadTestCase.cs000644 001750 001750 00000003371 11520622622 036502 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Tests; using Db4objects.Db4o.Internal; using Sharpen.Lang; namespace Db4oUnit.Extensions.Tests { public class UnhandledExceptionInThreadTestCase : ITestCase { public class ExceptionThrowingTestCase : AbstractDb4oTestCase { public virtual void Test() { Container().ThreadPool().Start(ReflectPlatform.SimpleName(typeof(UnhandledExceptionInThreadTestCase )) + " Throwing Exception Thread", new _IRunnable_15()); } private sealed class _IRunnable_15 : IRunnable { public _IRunnable_15() { } public void Run() { throw new InvalidOperationException(); } } } public virtual void TestSolo() { Db4oTestSuiteBuilder suite = new Db4oTestSuiteBuilder(new Db4oInMemory(), typeof( UnhandledExceptionInThreadTestCase.ExceptionThrowingTestCase)); TestResult result = new TestResult(); new TestRunner(suite).Run(result); Assert.AreEqual(1, result.Failures.Count); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/DynamicFixtureTestCase.cs000644 001750 001750 00000004320 11520622622 034307 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Tests; using Db4oUnit.Fixtures; namespace Db4oUnit.Extensions.Tests { public class DynamicFixtureTestCase : ITestSuiteBuilder { public virtual IEnumerator GetEnumerator() { // The test case simply runs FooTestSuite // with a Db4oInMemory fixture to ensure the // the db4o fixture can be successfully propagated // to FooTestUnit#test. return new Db4oTestSuiteBuilder(new Db4oInMemory(), typeof(DynamicFixtureTestCase.FooTestSuite )).GetEnumerator(); } /// One of the possibly many test units. /// One of the possibly many test units. public class FooTestUnit : AbstractDb4oTestCase { private readonly object[] values = MultiValueFixtureProvider.Value(); public virtual void Test() { Assert.IsNotNull(Db()); Assert.IsNotNull(values); } } /// The test suite which binds together fixture providers and test units. /// The test suite which binds together fixture providers and test units. public class FooTestSuite : FixtureTestSuiteDescription { public FooTestSuite() { { FixtureProviders(new IFixtureProvider[] { new MultiValueFixtureProvider(new object [][] { new object[] { "foo", "bar" }, new object[] { 1, 42 } }) }); TestUnits(new Type[] { typeof(DynamicFixtureTestCase.FooTestUnit) }); } } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/AllTests.cs000644 001750 001750 00000002352 11520622622 031456 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions.Tests; namespace Db4oUnit.Extensions.Tests { public class AllTests : ReflectionTestSuite { public static void Main(string[] args) { new Db4oUnit.Extensions.Tests.AllTests().Run(); } protected override Type[] TestCases() { return new Type[] { typeof(Db4oEmbeddedSessionFixtureTestCase), typeof(DynamicFixtureTestCase ), typeof(ExcludingReflectorTestCase), typeof(FixtureConfigurationTestCase), typeof( FixtureTestCase), typeof(UnhandledExceptionInThreadTestCase) }; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/NotAcceptedTestCase.cs000644 001750 001750 00000001736 11520622622 033555 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Tests { public class NotAcceptedTestCase : AbstractDb4oTestCase, IOptOutFromTestFixture { public virtual void Test() { Assert.Fail("Opted out test should not be run."); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/ExcludingReflectorTestCase.cs000644 001750 001750 00000003046 11520622622 035071 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Tests; using Db4objects.Db4o.Reflect; namespace Db4oUnit.Extensions.Tests { public class ExcludingReflectorTestCase : ITestCase { public class Excluded { } public virtual void TestExcludedClasses() { AssertNotVisible(typeof(ExcludingReflectorTestCase.Excluded)); } private void AssertNotVisible(Type type) { Assert.IsNull(ReflectClassForName(type.FullName)); } private IReflectClass ReflectClassForName(string className) { return new ExcludingReflector(new Type[] { typeof(ExcludingReflectorTestCase.Excluded ) }).ForName(className); } public virtual void TestVisibleClasses() { AssertVisible(GetType()); } private void AssertVisible(Type type) { Assert.IsNotNull(ReflectClassForName(type.FullName)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/AcceptedTestCase.cs000644 001750 001750 00000001527 11520622622 033072 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions.Tests { public class AcceptedTestCase : AbstractDb4oTestCase { public virtual void Test() { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/SimpleDb4oTestCase.cs000644 001750 001750 00000003506 11520622622 033323 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Tests; using Db4oUnit.Mocking; using Db4objects.Db4o.Config; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Extensions.Tests { public class SimpleDb4oTestCase : AbstractDb4oTestCase { public static readonly DynamicVariable RecorderVariable = DynamicVariable.NewInstance (); public class Data { } protected override void Configure(IConfiguration config) { Record(new MethodCall("fixture", new object[] { Fixture() })); Record(new MethodCall("configure", new object[] { config })); } private void Record(MethodCall call) { Recorder().Record(call); } private MethodCallRecorder Recorder() { return ((MethodCallRecorder)RecorderVariable.Value); } protected override void Store() { Record(new MethodCall("store", new object[] { })); Fixture().Db().Store(new SimpleDb4oTestCase.Data()); } public virtual void TestResultSize() { Record(new MethodCall("testResultSize", new object[] { })); Assert.AreEqual(1, Fixture().Db().QueryByExample(typeof(SimpleDb4oTestCase.Data)) .Count); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/MultipleDb4oTestCase.cs000644 001750 001750 00000002415 11520622622 033663 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions.Tests { public class MultipleDb4oTestCase : AbstractDb4oTestCase { private static int configureCalls = 0; public static void ResetConfigureCalls() { configureCalls = 0; } public static int ConfigureCalls() { return configureCalls; } protected override void Configure(IConfiguration config) { configureCalls++; } public virtual void TestFirst() { Assert.Fail(); } public virtual void TestSecond() { Assert.Fail(); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/Db4oEmbeddedSessionFixtureTestCase.cs000644 001750 001750 00000004203 11520622622 036412 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Tests; namespace Db4oUnit.Extensions.Tests { public class Db4oEmbeddedSessionFixtureTestCase : ITestCase { internal readonly Db4oEmbeddedSessionFixture subject = new Db4oEmbeddedSessionFixture (); public virtual void TestDoesNotAcceptRegularTest() { Assert.IsFalse(subject.Accept(typeof(Db4oEmbeddedSessionFixtureTestCase.RegularTest ))); } public virtual void TestAcceptsDb4oTest() { Assert.IsTrue(subject.Accept(typeof(Db4oEmbeddedSessionFixtureTestCase.Db4oTest)) ); } public virtual void TestDoesNotAcceptOptOutCS() { Assert.IsFalse(subject.Accept(typeof(Db4oEmbeddedSessionFixtureTestCase.OptOutTest ))); } public virtual void TestDoesNotAcceptOptOutAllButNetworkingCS() { Assert.IsFalse(subject.Accept(typeof(Db4oEmbeddedSessionFixtureTestCase.OptOutAllButNetworkingCSTest ))); } public virtual void TestAcceptsOptOutNetworking() { Assert.IsTrue(subject.Accept(typeof(Db4oEmbeddedSessionFixtureTestCase.OptOutNetworkingTest ))); } internal class RegularTest : ITestCase { } internal class Db4oTest : IDb4oTestCase { } internal class OptOutTest : IOptOutMultiSession { } internal class OptOutNetworkingTest : IOptOutNetworkingCS { } internal class OptOutAllButNetworkingCSTest : IOptOutAllButNetworkingCS { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/FixtureTestCase.cs000644 001750 001750 00000007271 11520622622 033012 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Tests; using Db4oUnit.Extensions.Util; using Db4oUnit.Mocking; using Db4oUnit.Tests; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Foundation.IO; using Sharpen.Lang; namespace Db4oUnit.Extensions.Tests { public class FixtureTestCase : ITestCase { private sealed class ExcludingInMemoryFixture : Db4oInMemory { public override bool Accept(Type clazz) { return !typeof(IOptOutFromTestFixture).IsAssignableFrom(clazz); } internal ExcludingInMemoryFixture(FixtureTestCase _enclosing) { this._enclosing = _enclosing; } private readonly FixtureTestCase _enclosing; } public virtual void TestSingleTestWithDifferentFixtures() { AssertSimpleDb4o(new Db4oInMemory()); AssertSimpleDb4o(new Db4oSolo()); } public virtual void TestMultipleTestsSingleFixture() { MultipleDb4oTestCase.ResetConfigureCalls(); FrameworkTestCase.RunTestAndExpect(new Db4oTestSuiteBuilder(new Db4oInMemory(), typeof( MultipleDb4oTestCase)), 2, false); Assert.AreEqual(2, MultipleDb4oTestCase.ConfigureCalls()); } public virtual void TestSelectiveFixture() { IDb4oFixture fixture = new FixtureTestCase.ExcludingInMemoryFixture(this); IEnumerator tests = new Db4oTestSuiteBuilder(fixture, new Type[] { typeof(AcceptedTestCase ), typeof(NotAcceptedTestCase) }).GetEnumerator(); ITest test = NextTest(tests); Assert.IsFalse(tests.MoveNext()); FrameworkTestCase.RunTestAndExpect(test, 0); } private void AssertSimpleDb4o(IDb4oFixture fixture) { IEnumerator tests = new Db4oTestSuiteBuilder(fixture, typeof(SimpleDb4oTestCase)) .GetEnumerator(); ITest test = NextTest(tests); MethodCallRecorder recorder = new MethodCallRecorder(); SimpleDb4oTestCase.RecorderVariable.With(recorder, new _IRunnable_46(test)); recorder.Verify(new MethodCall[] { new MethodCall("fixture", new object[] { fixture }), new MethodCall("configure", new object[] { MethodCall.IgnoredArgument }), new MethodCall("store", new object[] { }), new MethodCall("testResultSize", new object [] { }) }); } private sealed class _IRunnable_46 : IRunnable { public _IRunnable_46(ITest test) { this.test = test; } public void Run() { FrameworkTestCase.RunTestAndExpect(test, 0); } private readonly ITest test; } private ITest NextTest(IEnumerator tests) { return (ITest)Iterators.Next(tests); } public virtual void TestInterfaceIsAvailable() { Assert.IsTrue(typeof(IDb4oTestCase).IsAssignableFrom(typeof(AbstractDb4oTestCase) )); } /// public virtual void TestDeleteDir() { System.IO.Directory.CreateDirectory("a/b/c"); Assert.IsTrue(System.IO.File.Exists("a")); IOUtil.DeleteDir("a"); Assert.IsFalse(System.IO.File.Exists("a")); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Tests/FixtureConfigurationTestCase.cs000644 001750 001750 00000006054 11520622622 035461 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Tests; using Db4oUnit.Mocking; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions.Tests { public class FixtureConfigurationTestCase : ITestCase { internal sealed class MockFixtureConfiguration : MethodCallRecorder, IFixtureConfiguration { public void Configure(IDb4oTestCase testCase, IConfiguration config) { Record(new MethodCall("configure", new object[] { testCase, config })); } public string GetLabel() { return "MOCK"; } } public sealed class TestCase1 : AbstractDb4oTestCase { public void Test() { } } public sealed class TestCase2 : AbstractDb4oTestCase { public void Test() { } } public virtual void TestSolo() { AssertFixtureConfiguration(new Db4oSolo()); } public virtual void TestClientServer() { AssertFixtureConfiguration(Db4oFixtures.NewNetworkingCS()); } public virtual void TestInMemory() { AssertFixtureConfiguration(new Db4oInMemory()); } private void AssertFixtureConfiguration(IDb4oFixture fixture) { FixtureConfigurationTestCase.MockFixtureConfiguration configuration = new FixtureConfigurationTestCase.MockFixtureConfiguration (); fixture.FixtureConfiguration(configuration); Assert.IsTrue(fixture.Label().EndsWith(" - " + configuration.GetLabel()), "FixtureConfiguration label must be part of Fixture label." ); new TestRunner(new Db4oTestSuiteBuilder(fixture, new Type[] { typeof(FixtureConfigurationTestCase.TestCase1 ), typeof(FixtureConfigurationTestCase.TestCase2) })).Run(new TestResult()); configuration.Verify(new MethodCall[] { new MethodCall("configure", new object[] { MethodCall.Conditions.IsA(typeof(FixtureConfigurationTestCase.TestCase1)), MethodCall .IgnoredArgument }), new MethodCall("configure", new object[] { MethodCall.Conditions .IsA(typeof(FixtureConfigurationTestCase.TestCase1)), MethodCall.IgnoredArgument }), new MethodCall("configure", new object[] { MethodCall.Conditions.IsA(typeof( FixtureConfigurationTestCase.TestCase2)), MethodCall.IgnoredArgument }), new MethodCall ("configure", new object[] { MethodCall.Conditions.IsA(typeof(FixtureConfigurationTestCase.TestCase2 )), MethodCall.IgnoredArgument }) }); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/BTreeAssert.cs000644 001750 001750 00000011212 11520622622 030777 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Btree; using Db4objects.Db4o.Internal.Freespace; using Db4objects.Db4o.Internal.Handlers; using Db4objects.Db4o.Internal.Ids; using Db4objects.Db4o.Internal.Slots; namespace Db4oUnit.Extensions { public class BTreeAssert { public static void TraverseKeys(IBTreeRange result, IVisitor4 visitor) { IEnumerator i = result.Keys(); while (i.MoveNext()) { visitor.Visit(i.Current); } } public static void AssertKeys(Transaction transaction, BTree btree, int[] keys) { ExpectingVisitor visitor = ExpectingVisitor.CreateExpectingVisitor(keys); btree.TraverseKeys(transaction, visitor); visitor.AssertExpectations(); } public static void AssertEmpty(Transaction transaction, BTree tree) { ExpectingVisitor visitor = new ExpectingVisitor(new object[0]); tree.TraverseKeys(transaction, visitor); visitor.AssertExpectations(); Assert.AreEqual(0, tree.Size(transaction)); } public static void DumpKeys(Transaction trans, BTree tree) { tree.TraverseKeys(trans, new _IVisitor4_37()); } private sealed class _IVisitor4_37 : IVisitor4 { public _IVisitor4_37() { } public void Visit(object obj) { Sharpen.Runtime.Out.WriteLine(obj); } } public static int FillSize(BTree btree) { return btree.NodeSize() + 1; } public static int[] NewBTreeNodeSizedArray(BTree btree, int value) { return IntArrays4.Fill(new int[FillSize(btree)], value); } public static void AssertRange(int[] expectedKeys, IBTreeRange range) { Assert.IsNotNull(range); ExpectingVisitor visitor = ExpectingVisitor.CreateSortedExpectingVisitor(expectedKeys ); TraverseKeys(range, visitor); visitor.AssertExpectations(); } public static BTree CreateIntKeyBTree(ObjectContainerBase container, int id, int nodeSize) { return new BTree(container.SystemTransaction(), id, new IntHandler(), nodeSize); } public static void AssertSingleElement(Transaction trans, BTree btree, object element ) { Assert.AreEqual(1, btree.Size(trans)); IBTreeRange result = btree.SearchRange(trans, element); ExpectingVisitor expectingVisitor = new ExpectingVisitor(new object[] { element } ); BTreeAssert.TraverseKeys(result, expectingVisitor); expectingVisitor.AssertExpectations(); expectingVisitor = new ExpectingVisitor(new object[] { element }); btree.TraverseKeys(trans, expectingVisitor); expectingVisitor.AssertExpectations(); } /// public static void AssertAllSlotsFreed(LocalTransaction trans, BTree bTree, ICodeBlock block) { LocalObjectContainer container = (LocalObjectContainer)trans.Container(); ITransactionalIdSystem idSystem = trans.IdSystem(); IEnumerator allSlotIDs = bTree.AllNodeIds(trans.SystemTransaction()); Collection4 allSlots = new Collection4(); while (allSlotIDs.MoveNext()) { int slotID = ((int)allSlotIDs.Current); Slot slot = idSystem.CurrentSlot(slotID); allSlots.Add(slot); } Slot bTreeSlot = idSystem.CurrentSlot(bTree.GetID()); allSlots.Add(bTreeSlot); Collection4 freedSlots = new Collection4(); IFreespaceManager freespaceManager = container.FreespaceManager(); container.InstallDebugFreespaceManager(new FreespaceManagerForDebug(new _ISlotListener_99 (freedSlots))); block.Run(); container.InstallDebugFreespaceManager(freespaceManager); Assert.IsTrue(freedSlots.ContainsAll(allSlots.GetEnumerator())); } private sealed class _ISlotListener_99 : ISlotListener { public _ISlotListener_99(Collection4 freedSlots) { this.freedSlots = freedSlots; } public void OnFree(Slot slot) { freedSlots.Add(slot); } private readonly Collection4 freedSlots; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oTestSuiteBuilder.cs000644 001750 001750 00000004153 11520622622 032573 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Extensions { public class Db4oTestSuiteBuilder : ReflectionTestSuiteBuilder { private IDb4oFixture _fixture; public Db4oTestSuiteBuilder(IDb4oFixture fixture, Type clazz) : this(fixture, new Type[] { clazz }) { } public Db4oTestSuiteBuilder(IDb4oFixture fixture, Type[] classes) : base(classes) { Fixture(fixture); } private void Fixture(IDb4oFixture fixture) { if (null == fixture) { throw new ArgumentNullException("fixture"); } _fixture = fixture; } protected override bool IsApplicable(Type clazz) { return _fixture.Accept(clazz); } protected override ITest CreateTest(object instance, MethodInfo method) { ITest test = base.CreateTest(instance, method); return new _TestDecorationAdapter_38(test, test); } private sealed class _TestDecorationAdapter_38 : TestDecorationAdapter { public _TestDecorationAdapter_38(ITest test, ITest baseArg1) : base(baseArg1) { this.test = test; } public override string Label() { return "(" + Db4oFixtureVariable.Fixture().Label() + ") " + test.Label(); } private readonly ITest test; } protected override object WithContext(IClosure4 closure) { return Db4oFixtureVariable.FixtureVariable.With(_fixture, closure); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oConcurrencyTestCase.cs000644 001750 001750 00000003114 11520622622 033255 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Extensions { /// public class Db4oConcurrencyTestCase : Db4oClientServerTestCase { private bool[] _done; /// protected override void Db4oSetupAfterStore() { InitTasksDoneFlag(); base.Db4oSetupAfterStore(); } private void InitTasksDoneFlag() { _done = new bool[ThreadCount()]; } protected virtual void MarkTaskDone(int seq, bool done) { _done[seq] = done; } /// protected virtual void WaitForAllTasksDone() { while (!AreAllTasksDone()) { Runtime4.Sleep(1); } } private bool AreAllTasksDone() { for (int i = 0; i < _done.Length; ++i) { if (!_done[i]) { return false; } } return true; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IContainerBlock.cs000644 001750 001750 00000001556 11520622622 031634 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o; namespace Db4oUnit.Extensions { public interface IContainerBlock { /// void Run(IObjectContainer client); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oAssert.cs000644 001750 001750 00000002174 11520622622 030575 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Db4o.Ext; namespace Db4oUnit.Extensions { public class Db4oAssert { public static void PersistedCount(int expected, Type extent) { Assert.AreEqual(expected, Db().Query(extent).Count); } private static IExtObjectContainer Db() { return Fixture().Db(); } private static IDb4oFixture Fixture() { return Db4oFixtureVariable.Fixture(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/AbstractDb4oTestCase.cs000644 001750 001750 00000027174 11520622622 032542 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Concurrency; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Events; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Marshall; using Db4objects.Db4o.Query; using Db4objects.Db4o.Reflect; namespace Db4oUnit.Extensions { public partial class AbstractDb4oTestCase : IDb4oTestCase, ITestLifeCycle { private const int DefaultConcurrencyThreadCount = 10; [System.NonSerialized] private int _threadCount = DefaultConcurrencyThreadCount; public static IDb4oFixture Fixture() { return Db4oFixtureVariable.Fixture(); } public virtual bool IsMultiSession() { return Fixture() is IMultiSessionFixture; } protected virtual bool IsEmbedded() { return Fixture() is Db4oEmbeddedSessionFixture; } protected virtual bool IsNetworking() { return Fixture() is Db4oNetworking; } public virtual IExtObjectContainer OpenNewSession() { IMultiSessionFixture fixture = (IMultiSessionFixture)Fixture(); try { return fixture.OpenNewSession(this); } catch (Exception e) { throw new Db4oException(e); } } /// protected virtual void Reopen() { Fixture().Reopen(this); } /// public void SetUp() { IDb4oFixture _fixture = Fixture(); _fixture.Clean(); Db4oSetupBeforeConfigure(); Configure(_fixture.Config()); _fixture.Open(this); Db4oSetupBeforeStore(); Store(); _fixture.Db().Commit(); _fixture.Close(); _fixture.Open(this); Db4oSetupAfterStore(); } /// public void TearDown() { try { Db4oTearDownBeforeClean(); } finally { IDb4oFixture fixture = Fixture(); fixture.Close(); IList uncaughtExceptions = fixture.UncaughtExceptions(); fixture.Clean(); HandleUncaughtExceptions(uncaughtExceptions); } Db4oTearDownAfterClean(); } protected virtual void HandleUncaughtExceptions(IList uncaughtExceptions) { if (uncaughtExceptions.Count > 0) { Assert.Fail("Uncaught exceptions: " + Iterators.Join(Iterators.Iterator(uncaughtExceptions ), ", "), ((Exception)uncaughtExceptions[0])); } } /// protected virtual void Db4oSetupBeforeConfigure() { } /// protected virtual void Db4oSetupBeforeStore() { } /// protected virtual void Db4oSetupAfterStore() { } /// protected virtual void Db4oTearDownBeforeClean() { } /// protected virtual void Db4oTearDownAfterClean() { } /// protected virtual void Configure(IConfiguration config) { } /// protected virtual void Store() { } public virtual IExtObjectContainer Db() { return Fixture().Db(); } protected virtual Type[] TestCases() { return new Type[] { GetType() }; } public virtual int RunAll() { return new ConsoleTestRunner(Iterators.Concat(new IEnumerable[] { SoloSuite(), NetworkingSuite (), EmbeddedSuite() })).Run(); } public virtual int RunSolo(string testLabelSubstring) { return new ConsoleTestRunner(Iterators.Filter(SoloSuite(), new _IPredicate4_131(testLabelSubstring ))).Run(); } private sealed class _IPredicate4_131 : IPredicate4 { public _IPredicate4_131(string testLabelSubstring) { this.testLabelSubstring = testLabelSubstring; } public bool Match(object candidate) { return (((ITest)candidate).Label().IndexOf(testLabelSubstring) >= 0); } private readonly string testLabelSubstring; } public virtual int RunSoloAndClientServer() { return new ConsoleTestRunner(Iterators.Concat(new IEnumerable[] { SoloSuite(), NetworkingSuite () })).Run(); } public virtual int RunSoloAndEmbeddedClientServer() { return new ConsoleTestRunner(Iterators.Concat(new IEnumerable[] { SoloSuite(), EmbeddedSuite () })).Run(); } public virtual int RunSolo() { return new ConsoleTestRunner(SoloSuite()).Run(); } public virtual int RunInMemory() { return new ConsoleTestRunner(InMemorySuite()).Run(); } public virtual int RunNetworking() { return new ConsoleTestRunner(NetworkingSuite()).Run(); } public virtual int RunEmbedded() { return new ConsoleTestRunner(EmbeddedSuite()).Run(); } public virtual int RunConcurrency() { return new ConsoleTestRunner(ConcurrenyClientServerSuite(false, "CONC")).Run(); } public virtual int RunEmbeddedConcurrency() { return new ConsoleTestRunner(ConcurrenyClientServerSuite(true, "CONC EMBEDDED")). Run(); } public virtual int RunConcurrencyAll() { return new ConsoleTestRunner(Iterators.Concat(new IEnumerable[] { ConcurrenyClientServerSuite (false, "CONC"), ConcurrenyClientServerSuite(true, "CONC EMBEDDED") })).Run(); } protected virtual Db4oTestSuiteBuilder SoloSuite() { return new Db4oTestSuiteBuilder(Db4oFixtures.NewSolo(), TestCases()); } protected virtual Db4oTestSuiteBuilder InMemorySuite() { return new Db4oTestSuiteBuilder(Db4oFixtures.NewInMemory(), TestCases()); } protected virtual Db4oTestSuiteBuilder NetworkingSuite() { return new Db4oTestSuiteBuilder(Db4oFixtures.NewNetworkingCS(), TestCases()); } protected virtual Db4oTestSuiteBuilder EmbeddedSuite() { return new Db4oTestSuiteBuilder(Db4oFixtures.NewEmbedded(), TestCases()); } protected virtual Db4oTestSuiteBuilder ConcurrenyClientServerSuite(bool embedded, string label) { return new Db4oConcurrencyTestSuiteBuilder(embedded ? Db4oFixtures.NewEmbedded(label ) : Db4oFixtures.NewNetworkingCS(label), TestCases()); } protected virtual IInternalObjectContainer Stream() { return (IInternalObjectContainer)Db(); } protected virtual ObjectContainerBase Container() { return Stream().Container; } public virtual LocalObjectContainer FileSession() { return Fixture().FileSession(); } public virtual Transaction Trans() { return ((IInternalObjectContainer)Db()).Transaction; } protected virtual Transaction SystemTrans() { return Trans().SystemTransaction(); } protected virtual IQuery NewQuery(Transaction transaction, Type clazz) { IQuery query = NewQuery(transaction); query.Constrain(clazz); return query; } protected virtual IQuery NewQuery(Transaction transaction) { return Container().Query(transaction); } protected virtual IQuery NewQuery() { return NewQuery(Db()); } protected static IQuery NewQuery(IExtObjectContainer oc) { return oc.Query(); } protected virtual IQuery NewQuery(Type clazz) { return NewQuery(Db(), clazz); } protected static IQuery NewQuery(IExtObjectContainer oc, Type clazz) { IQuery query = NewQuery(oc); query.Constrain(clazz); return query; } protected virtual IReflector Reflector() { return Stream().Reflector(); } protected virtual void IndexField(IConfiguration config, Type clazz, string fieldName ) { config.ObjectClass(clazz).ObjectField(fieldName).Indexed(true); } protected virtual Transaction NewTransaction() { lock (Container().Lock()) { return Container().NewUserTransaction(); } } public virtual object RetrieveOnlyInstance(Type clazz) { return RetrieveOnlyInstance(Db(), clazz); } public static object RetrieveOnlyInstance(IExtObjectContainer oc, Type clazz) { IObjectSet result = NewQuery(oc, clazz).Execute(); Assert.AreEqual(1, result.Count); return result.Next(); } protected virtual int CountOccurences(Type clazz) { return CountOccurences(Db(), clazz); } protected virtual int CountOccurences(IExtObjectContainer oc, Type clazz) { IObjectSet result = NewQuery(oc, clazz).Execute(); return result.Count; } protected virtual void AssertOccurrences(Type clazz, int expected) { AssertOccurrences(Db(), clazz, expected); } protected virtual void AssertOccurrences(IExtObjectContainer oc, Type clazz, int expected) { Assert.AreEqual(expected, CountOccurences(oc, clazz)); } protected virtual void Foreach(Type clazz, IVisitor4 visitor) { Foreach(Db(), clazz, visitor); } protected virtual void Foreach(IExtObjectContainer container, Type clazz, IVisitor4 visitor) { IObjectSet set = NewQuery(container, clazz).Execute(); while (set.HasNext()) { visitor.Visit(set.Next()); } } protected void DeleteAll(Type clazz) { DeleteAll(Db(), clazz); } protected void DeleteAll(IExtObjectContainer oc, Type clazz) { Foreach(oc, clazz, new _IVisitor4_316(oc)); } private sealed class _IVisitor4_316 : IVisitor4 { public _IVisitor4_316(IExtObjectContainer oc) { this.oc = oc; } public void Visit(object obj) { oc.Delete(obj); } private readonly IExtObjectContainer oc; } protected void DeleteObjectSet(IObjectSet os) { DeleteObjectSet(Db(), os); } protected void DeleteObjectSet(IObjectContainer oc, IObjectSet os) { while (os.HasNext()) { oc.Delete(os.Next()); } } public void Store(object obj) { Db().Store(obj); } protected virtual ClassMetadata ClassMetadataFor(Type clazz) { return Stream().ClassMetadataForReflectClass(ReflectClass(clazz)); } protected virtual IReflectClass ReflectClass(Type clazz) { return Reflector().ForClass(clazz); } /// protected virtual void Defragment() { Fixture().Close(); Fixture().Defragment(); Fixture().Open(this); } public int ThreadCount() { return _threadCount; } public void ConfigureThreadCount(int count) { _threadCount = count; } protected virtual IEventRegistry EventRegistry() { return EventRegistryFor(Db()); } protected virtual IEventRegistry EventRegistryFor(IExtObjectContainer container) { return EventRegistryFactory.ForObjectContainer(container); } protected virtual IEventRegistry ServerEventRegistry() { return EventRegistryFor(FileSession()); } protected virtual IContext Context() { return Trans().Context(); } protected virtual void Commit() { Db().Commit(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutStackOverflowIssue.cs000644 001750 001750 00000001520 11520622622 033703 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public interface IOptOutStackOverflowIssue : IOptOutAndroid { // related to issue COR-2010 } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oClientServerTestCase.cs000644 001750 001750 00000001736 11520622622 033400 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions { public class Db4oClientServerTestCase : AbstractDb4oTestCase, IOptOutSolo { public virtual IDb4oClientServerFixture ClientServerFixture() { return (IDb4oClientServerFixture)Fixture(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ComposibleReflectionTestSuite.cs000644 001750 001750 00000002056 11520622622 034603 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public abstract class ComposibleReflectionTestSuite : ReflectionTestSuite { protected virtual Type[] ComposeTests(Type[] classes) { return ComposibleTestSuite.Concat(classes, ComposeWith()); } protected virtual Type[] ComposeWith() { return new Type[0]; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/000755 001750 001750 00000000000 11520622070 030076 5ustar00directhexdirecthex000000 000000 src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutFromTestFixture.cs000644 001750 001750 00000002347 11520622622 034755 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions.Fixtures { /// /// 'Abstract' marker interface to denote that implementing test cases should be /// excluded from running against specific fixtures. /// /// /// 'Abstract' marker interface to denote that implementing test cases should be /// excluded from running against specific fixtures. Concrete marker interfaces /// for specific fixtures should extend OptOutFromTestFixture. /// public interface IOptOutFromTestFixture : IDb4oTestCase { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutNoInheritedClassPath.cs000644 001750 001750 00000002530 11520622622 035650 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases using JavaServices /// should be excluded from fixtures that run in an environment where the classpath /// is not captured in the java.class.path system property. /// /// /// Marker interface to denote that implementing test cases using JavaServices /// should be excluded from fixtures that run in an environment where the classpath /// is not captured in the java.class.path system property. /// public interface IOptOutNoInheritedClassPath : IOptOutFromTestFixture { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/AbstractDb4oFixture.cs000644 001750 001750 00000011744 11520622622 034262 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit.Extensions; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Defragment; using Db4objects.Db4o.Events; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Threading; namespace Db4oUnit.Extensions.Fixtures { public abstract class AbstractDb4oFixture : IDb4oFixture { private IFixtureConfiguration _fixtureConfiguration; private IConfiguration _configuration; private IList _uncaughtExceptions; protected AbstractDb4oFixture() { ResetUncaughtExceptions(); } private void ResetUncaughtExceptions() { _uncaughtExceptions = new ArrayList(); } public virtual void FixtureConfiguration(IFixtureConfiguration fc) { _fixtureConfiguration = fc; } public virtual IList UncaughtExceptions() { return _uncaughtExceptions; } protected virtual void ListenToUncaughtExceptions(IThreadPool4 threadPool) { if (null == threadPool) { return; } // mocks don't have thread pools threadPool.UncaughtException += new System.EventHandler (new _IEventListener4_42(this).OnEvent); } private sealed class _IEventListener4_42 { public _IEventListener4_42(AbstractDb4oFixture _enclosing) { this._enclosing = _enclosing; } public void OnEvent(object sender, UncaughtExceptionEventArgs args) { this._enclosing._uncaughtExceptions.Add(((UncaughtExceptionEventArgs)args).Exception ); } private readonly AbstractDb4oFixture _enclosing; } /// public virtual void Reopen(IDb4oTestCase testInstance) { Close(); Open(testInstance); } public virtual IConfiguration Config() { if (_configuration == null) { _configuration = NewConfiguration(); } return _configuration; } public virtual void Clean() { DoClean(); ResetConfig(); ResetUncaughtExceptions(); } public abstract bool Accept(Type clazz); protected abstract void DoClean(); public virtual void ResetConfig() { _configuration = null; } /// Method can be overridden in subclasses with special instantiation requirements (oSGI for instance). /// /// Method can be overridden in subclasses with special instantiation requirements (oSGI for instance). /// /// protected virtual IConfiguration NewConfiguration() { return Db4oFactory.NewConfiguration(); } /// protected virtual void Defragment(string fileName) { string targetFile = fileName + ".defrag.backup"; DefragmentConfig defragConfig = new DefragmentConfig(fileName, targetFile); defragConfig.ForceBackupDelete(true); defragConfig.Db4oConfig(CloneConfiguration()); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig); } protected virtual string BuildLabel(string label) { if (null == _fixtureConfiguration) { return label; } return label + " - " + _fixtureConfiguration.GetLabel(); } protected virtual void ApplyFixtureConfiguration(IDb4oTestCase testInstance, IConfiguration config) { if (null == _fixtureConfiguration) { return; } _fixtureConfiguration.Configure(testInstance, config); } public override string ToString() { return Label(); } protected virtual Config4Impl CloneConfiguration() { return CloneDb4oConfiguration((Config4Impl)Config()); } protected virtual Config4Impl CloneDb4oConfiguration(IConfiguration config) { return (Config4Impl)((Config4Impl)config).DeepClone(this); } protected virtual IThreadPool4 ThreadPoolFor(IObjectContainer container) { if (container is ObjectContainerBase) { return ((ObjectContainerBase)container).ThreadPool(); } return null; } public abstract string Label(); public abstract void Close(); public abstract void ConfigureAtRuntime(IRuntimeConfigureAction arg1); public abstract IExtObjectContainer Db(); public abstract void Defragment(); public abstract LocalObjectContainer FileSession(); public abstract void Open(IDb4oTestCase arg1); } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/NonStandardBlockSizeFixture.cs000644 001750 001750 00000002412 11520622622 035740 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions.Fixtures { public class NonStandardBlockSizeFixture : Db4oSolo { protected override IObjectContainer CreateDatabase(IConfiguration config) { config.BlockSize(7); return base.CreateDatabase(config); } public override bool Accept(Type clazz) { return base.Accept(clazz) && !typeof(IOptOutNonStandardBlockSize).IsAssignableFrom (clazz); } public override string Label() { return "BlockSize-" + base.Label(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oDefragSolo.cs000644 001750 001750 00000004664 11520622622 033200 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Defragment; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Extensions.Fixtures { public class Db4oDefragSolo : Db4oSolo { protected override IObjectContainer CreateDatabase(IConfiguration config) { Sharpen.IO.File origFile = new Sharpen.IO.File(GetAbsolutePath()); if (origFile.Exists()) { try { string backupFile = GetAbsolutePath() + ".defrag.backup"; IIdMapping mapping = new InMemoryIdMapping(); // new // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000); DefragmentConfig defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile , mapping); defragConfig.ForceBackupDelete(true); // FIXME Cloning is ugly - wrap original in Decorator within // DefragContext instead? IConfiguration clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null ); defragConfig.Db4oConfig(clonedConfig); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_30 ()); } catch (IOException e) { Sharpen.Runtime.PrintStackTrace(e); } } return base.CreateDatabase(config); } private sealed class _IDefragmentListener_30 : IDefragmentListener { public _IDefragmentListener_30() { } public void NotifyDefragmentInfo(DefragmentInfo info) { Sharpen.Runtime.Err.WriteLine(info); } } public override bool Accept(Type clazz) { return base.Accept(clazz) && !typeof(IOptOutDefragSolo).IsAssignableFrom(clazz); } public override string Label() { return "Defrag-" + base.Label(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IdSystemFixture.cs000644 001750 001750 00000005275 11520622622 033551 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Internal.Config; using Db4objects.Db4o.Internal.Ids; namespace Db4oUnit.Extensions.Fixtures { public class IdSystemFixture : Db4oSolo { private readonly byte _idSystemType; public IdSystemFixture(byte idSystemType) { _idSystemType = idSystemType; } public IdSystemFixture() { _idSystemType = StandardIdSystemFactory.StackedBtree; } protected override IObjectContainer CreateDatabase(IConfiguration config) { IEmbeddedConfiguration embeddedConfiguration = Db4oLegacyConfigurationBridge.AsEmbeddedConfiguration (config); switch (_idSystemType) { case StandardIdSystemFactory.PointerBased: { embeddedConfiguration.IdSystem.UsePointerBasedSystem(); break; } case StandardIdSystemFactory.StackedBtree: { embeddedConfiguration.IdSystem.UseStackedBTreeSystem(); break; } case StandardIdSystemFactory.InMemory: { embeddedConfiguration.IdSystem.UseInMemorySystem(); break; } default: { throw new InvalidOperationException(); } } // embeddedConfiguration.file().freespace().useBTreeSystem(); return base.CreateDatabase(config); } public override string Label() { string idSystemType = string.Empty; switch (_idSystemType) { case StandardIdSystemFactory.PointerBased: { idSystemType = "PointerBased"; break; } case StandardIdSystemFactory.StackedBtree: { idSystemType = "BTree"; break; } case StandardIdSystemFactory.InMemory: { idSystemType = "InMemory"; break; } default: { throw new InvalidOperationException(); } } return "IdSystem-" + idSystemType + " " + base.Label(); } public override bool Accept(Type clazz) { return base.Accept(clazz) && !typeof(IOptOutIdSystem).IsAssignableFrom(clazz); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IDb4oClientServerFixture.cs000644 001750 001750 00000001673 11520622622 035156 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; namespace Db4oUnit.Extensions.Fixtures { public interface IDb4oClientServerFixture : IDb4oFixture, IMultiSessionFixture { IObjectServer Server(); int ServerPort(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oFixtureProvider.cs000644 001750 001750 00000002144 11520622622 034303 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4oUnit.Extensions; using Db4oUnit.Fixtures; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Extensions.Fixtures { public class Db4oFixtureProvider : IFixtureProvider { public virtual FixtureVariable Variable() { return Db4oFixtureVariable.FixtureVariable; } public virtual IEnumerator GetEnumerator() { return Iterators.SingletonIterator(Variable().Value); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutNonStandardBlockSize.cs000644 001750 001750 00000001514 11520622622 035657 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public interface IOptOutNonStandardBlockSize : IOptOutFromTestFixture { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oInMemory.cs000644 001750 001750 00000004170 11520622622 032702 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.IO; namespace Db4oUnit.Extensions.Fixtures { public class Db4oInMemory : AbstractSoloDb4oFixture { private static readonly string DbUri = "test_db"; public Db4oInMemory() : base() { } public Db4oInMemory(IFixtureConfiguration fc) : this() { FixtureConfiguration(fc); } public override bool Accept(Type clazz) { if (!base.Accept(clazz)) { return false; } if (typeof(IOptOutInMemory).IsAssignableFrom(clazz)) { return false; } return true; } private readonly PagingMemoryStorage _storage = new PagingMemoryStorage(63); protected override IObjectContainer CreateDatabase(IConfiguration config) { return Db4oFactory.OpenFile(config, DbUri); } protected override IConfiguration NewConfiguration() { IConfiguration config = base.NewConfiguration(); config.Storage = _storage; return config; } protected override void DoClean() { try { _storage.Delete(DbUri); } catch (IOException exc) { Sharpen.Runtime.PrintStackTrace(exc); } } public override string Label() { return BuildLabel("IN-MEMORY"); } /// public override void Defragment() { Defragment(DbUri); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutDefragSolo.cs000644 001750 001750 00000002216 11520622622 033742 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running against a defragmenting fixture. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running against a defragmenting fixture. /// public interface IOptOutDefragSolo : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/ICustomClientServerConfiguration.cs000644 001750 001750 00000002056 11520622622 037015 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions.Fixtures { public interface ICustomClientServerConfiguration : IDb4oTestCase { /// void ConfigureServer(IConfiguration config); /// void ConfigureClient(IConfiguration config); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IMultiSessionFixture.cs000644 001750 001750 00000001710 11520622622 034545 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o.Ext; namespace Db4oUnit.Extensions.Fixtures { public interface IMultiSessionFixture : IDb4oFixture { /// IExtObjectContainer OpenNewSession(IDb4oTestCase testInstance); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutNetworkingCS.cs000644 001750 001750 00000002244 11520622622 034273 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running with the networking Client/Server fixture. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running with the networking Client/Server fixture. /// public interface IOptOutNetworkingCS : IOptOutFromTestFixture { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutIdSystem.cs000644 001750 001750 00000001500 11520622622 033451 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public interface IOptOutIdSystem : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/AbstractSoloDb4oFixture.cs000644 001750 001750 00000004671 11520622622 035041 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Threading; namespace Db4oUnit.Extensions.Fixtures { public abstract class AbstractSoloDb4oFixture : AbstractDb4oFixture { private IExtObjectContainer _db; protected AbstractSoloDb4oFixture() { } public sealed override void Open(IDb4oTestCase testInstance) { Assert.IsNull(_db); IConfiguration config = CloneConfiguration(); ApplyFixtureConfiguration(testInstance, config); _db = CreateDatabase(config).Ext(); ListenToUncaughtExceptions(ThreadPool()); PostOpen(testInstance); } private IThreadPool4 ThreadPool() { return ThreadPoolFor(_db); } /// public override void Close() { try { PreClose(); } finally { if (null != _db) { Assert.IsTrue(_db.Close()); try { ThreadPool().Join(3000); } finally { _db = null; } } } } public override bool Accept(Type clazz) { return !typeof(IOptOutSolo).IsAssignableFrom(clazz); } public override IExtObjectContainer Db() { return _db; } public override LocalObjectContainer FileSession() { return (LocalObjectContainer)_db; } public override void ConfigureAtRuntime(IRuntimeConfigureAction action) { action.Apply(Config()); } protected virtual void PreClose() { } protected virtual void PostOpen(IDb4oTestCase testInstance) { } protected abstract IObjectContainer CreateDatabase(IConfiguration config); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oSolo.cs000644 001750 001750 00000002303 11520622622 032053 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public class Db4oSolo : AbstractFileBasedDb4oFixture { private static readonly string File = "db4oSoloTest.db4o"; public Db4oSolo() { } public Db4oSolo(IFixtureConfiguration fixtureConfiguration) { FixtureConfiguration(fixtureConfiguration); } public override string Label() { return BuildLabel("SOLO"); } protected override string FileName() { return File; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oFixtures.cs000644 001750 001750 00000002572 11520622622 032760 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public class Db4oFixtures { public static Db4oSolo NewSolo() { return new Db4oSolo(); } public static Db4oInMemory NewInMemory() { return new Db4oInMemory(); } public static IMultiSessionFixture NewEmbedded() { return new Db4oEmbeddedSessionFixture(); } public static IMultiSessionFixture NewEmbedded(string label) { return new Db4oEmbeddedSessionFixture(label); } public static Db4oNetworking NewNetworkingCS() { return new Db4oNetworking(); } public static Db4oNetworking NewNetworkingCS(string label) { return new Db4oNetworking(label); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutCustomContainerInstantiation.cs000644 001750 001750 00000002420 11520622622 037515 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Opts out from fixtures that require customized ways of creating/opening ObjectContainer /// instances and won't work with test cases explicitly invoking the common factory methods. /// /// /// Opts out from fixtures that require customized ways of creating/opening ObjectContainer /// instances and won't work with test cases explicitly invoking the common factory methods. /// public interface IOptOutCustomContainerInstantiation : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutBTreeFreespaceManager.cs000644 001750 001750 00000001515 11520622622 035751 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public interface IOptOutBTreeFreespaceManager : IOptOutFromTestFixture { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oNetworking.cs000644 001750 001750 00000017463 11520622622 033303 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !SILVERLIGHT using System; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Util; using Db4objects.Db4o; using Db4objects.Db4o.CS.Config; using Db4objects.Db4o.CS.Internal.Config; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Threading; namespace Db4oUnit.Extensions.Fixtures { public class Db4oNetworking : AbstractDb4oFixture, IDb4oClientServerFixture { private const int ThreadpoolTimeout = 3000; protected static readonly string File = "Db4oClientServer.db4o"; public static readonly string Host = "127.0.0.1"; public static readonly string Username = "db4o"; public static readonly string Password = Username; private IObjectServer _server; private readonly Sharpen.IO.File _file; private IExtObjectContainer _objectContainer; private string _label; private int _port; private IConfiguration _serverConfig; private readonly IClientServerFactory _csFactory; public Db4oNetworking(IClientServerFactory csFactory, string label) { _csFactory = csFactory != null ? csFactory : DefaultClientServerFactory(); _file = new Sharpen.IO.File(FilePath()); _label = label; } private IClientServerFactory DefaultClientServerFactory() { return new StandardClientServerFactory(); } public Db4oNetworking(string label) : this(null, label) { } public Db4oNetworking() : this("C/S") { } /// public override void Open(IDb4oTestCase testInstance) { OpenServerFor(testInstance); OpenClientFor(testInstance); ListenToUncaughtExceptions(); } private void ListenToUncaughtExceptions() { ListenToUncaughtExceptions(ServerThreadPool()); IThreadPool4 clientThreadPool = ClientThreadPool(); if (null != clientThreadPool) { ListenToUncaughtExceptions(clientThreadPool); } } private IThreadPool4 ClientThreadPool() { return ThreadPoolFor(_objectContainer); } private IThreadPool4 ServerThreadPool() { return ThreadPoolFor(_server.Ext().ObjectContainer()); } /// private void OpenClientFor(IDb4oTestCase testInstance) { IConfiguration config = ClientConfigFor(testInstance); _objectContainer = OpenClientWith(config); } /// private IConfiguration ClientConfigFor(IDb4oTestCase testInstance) { if (RequiresCustomConfiguration(testInstance)) { IConfiguration customServerConfig = NewConfiguration(); ((ICustomClientServerConfiguration)testInstance).ConfigureClient(customServerConfig ); return customServerConfig; } IConfiguration config = CloneConfiguration(); ApplyFixtureConfiguration(testInstance, config); return config; } private IExtObjectContainer OpenSocketClient(IConfiguration config) { return _csFactory.OpenClient(AsClientConfiguration(config), Host, _port, Username , Password).Ext(); } /// public virtual IExtObjectContainer OpenNewSession(IDb4oTestCase testInstance) { IConfiguration config = ClientConfigFor(testInstance); return OpenClientWith(config); } private IExtObjectContainer OpenClientWith(IConfiguration config) { return OpenSocketClient(config); } /// private void OpenServerFor(IDb4oTestCase testInstance) { _serverConfig = ServerConfigFor(testInstance); _server = _csFactory.OpenServer(AsServerConfiguration(_serverConfig), _file.GetAbsolutePath (), -1); _port = _server.Ext().Port(); _server.GrantAccess(Username, Password); } /// private IConfiguration ServerConfigFor(IDb4oTestCase testInstance) { if (RequiresCustomConfiguration(testInstance)) { IConfiguration customServerConfig = NewConfiguration(); ((ICustomClientServerConfiguration)testInstance).ConfigureServer(customServerConfig ); return customServerConfig; } return CloneConfiguration(); } private bool RequiresCustomConfiguration(IDb4oTestCase testInstance) { if (testInstance is ICustomClientServerConfiguration) { return true; } return false; } /// public override void Close() { if (null != _objectContainer) { IThreadPool4 clientThreadPool = ClientThreadPool(); _objectContainer.Close(); _objectContainer = null; if (null != clientThreadPool) { clientThreadPool.Join(ThreadpoolTimeout); } } CloseServer(); } /// private void CloseServer() { if (null != _server) { IThreadPool4 serverThreadPool = ServerThreadPool(); _server.Close(); _server = null; if (null != serverThreadPool) { serverThreadPool.Join(ThreadpoolTimeout); } } } public override IExtObjectContainer Db() { return _objectContainer; } protected override void DoClean() { _file.Delete(); } public virtual IObjectServer Server() { return _server; } /// /// Does not accept a clazz which is assignable from OptOutCS, or not /// assignable from Db4oTestCase. /// /// /// Does not accept a clazz which is assignable from OptOutCS, or not /// assignable from Db4oTestCase. /// /// /// returns false if the clazz is assignable from OptOutCS, or not /// assignable from Db4oTestCase. Otherwise, returns true. /// public override bool Accept(Type clazz) { if (!typeof(IDb4oTestCase).IsAssignableFrom(clazz)) { return false; } if (typeof(IOptOutMultiSession).IsAssignableFrom(clazz)) { return false; } if (typeof(IOptOutNetworkingCS).IsAssignableFrom(clazz)) { return false; } return true; } public override LocalObjectContainer FileSession() { return (LocalObjectContainer)_server.Ext().ObjectContainer(); } /// public override void Defragment() { Defragment(FilePath()); } public override string Label() { return BuildLabel(_label); } public virtual int ServerPort() { return _port; } private static string FilePath() { return CrossPlatformServices.DatabasePath(File); } public override void ConfigureAtRuntime(IRuntimeConfigureAction action) { action.Apply(Config()); action.Apply(_serverConfig); } private IClientConfiguration AsClientConfiguration(IConfiguration serverConfig) { return Db4oClientServerLegacyConfigurationBridge.AsClientConfiguration(serverConfig ); } private IServerConfiguration AsServerConfiguration(IConfiguration serverConfig) { return Db4oClientServerLegacyConfigurationBridge.AsServerConfiguration(serverConfig ); } } } #endif // !SILVERLIGHT db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutSolo.cs000644 001750 001750 00000002160 11520622622 032627 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running with a Solo fixture. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running with a Solo fixture. /// public interface IOptOutSolo : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutNoFileSystemData.cs000644 001750 001750 00000002562 11520622622 035015 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running within a fixture that may not provide access to required data /// on the file system. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running within a fixture that may not provide access to required data /// on the file system. (This opt-out probably should be replaced by a less /// file system dependent access mechanism to this data.) /// public interface IOptOutNoFileSystemData : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/BTreeFreespaceManagerFixture.cs000644 001750 001750 00000002441 11520622622 036033 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions.Fixtures { public class BTreeFreespaceManagerFixture : Db4oSolo { protected override IObjectContainer CreateDatabase(IConfiguration config) { config.Freespace().UseBTreeSystem(); return base.CreateDatabase(config); } public override bool Accept(Type clazz) { return base.Accept(clazz) && !typeof(IOptOutBTreeFreespaceManager).IsAssignableFrom (clazz); } public override string Label() { return "BTreeFreespace-" + base.Label(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutMultiSession.cs000644 001750 001750 00000002310 11520622622 034346 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running both with the embedded and networking Client/Server fixture. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running both with the embedded and networking Client/Server fixture. /// public interface IOptOutMultiSession : IOptOutFromTestFixture { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutSilverlight.cs000644 001750 001750 00000002205 11520622622 034207 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running in silverlight environment. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running in silverlight environment. /// public interface IOptOutSilverlight : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oEmbeddedSessionFixture.cs000644 001750 001750 00000004202 11520622622 035464 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o.Ext; namespace Db4oUnit.Extensions.Fixtures { public class Db4oEmbeddedSessionFixture : AbstractFileBasedDb4oFixture, IMultiSessionFixture { private static readonly string File = "db4oEmbeddedSession.db4o"; private readonly string _label; private IExtObjectContainer _session; public Db4oEmbeddedSessionFixture(string label) { _label = label; } public Db4oEmbeddedSessionFixture() : this("E/S") { } public override string Label() { return BuildLabel(_label); } public override IExtObjectContainer Db() { return _session; } protected override string FileName() { return File; } public override bool Accept(Type clazz) { if (!typeof(IDb4oTestCase).IsAssignableFrom(clazz)) { return false; } if (typeof(IOptOutMultiSession).IsAssignableFrom(clazz)) { return false; } if (typeof(IOptOutAllButNetworkingCS).IsAssignableFrom(clazz)) { return false; } return true; } protected override void PostOpen(IDb4oTestCase testInstance) { _session = OpenNewSession(testInstance); } protected override void PreClose() { if (null != _session) { _session.Close(); } } public virtual IExtObjectContainer OpenNewSession(IDb4oTestCase testInstance) { return FileSession().OpenSession().Ext(); } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/AbstractFileBasedDb4oFixture.cs000644 001750 001750 00000003264 11520622622 035740 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Extensions.Util; using Db4objects.Db4o; using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions.Fixtures { public abstract class AbstractFileBasedDb4oFixture : AbstractSoloDb4oFixture { private readonly Sharpen.IO.File _databaseFile; public AbstractFileBasedDb4oFixture() { string fileName = FileName(); _databaseFile = new Sharpen.IO.File(CrossPlatformServices.DatabasePath(fileName)); } protected abstract string FileName(); protected override IObjectContainer CreateDatabase(IConfiguration config) { return Db4oFactory.OpenFile(config, GetAbsolutePath()); } public virtual string GetAbsolutePath() { return _databaseFile.GetAbsolutePath(); } /// public override void Defragment() { Defragment(GetAbsolutePath()); } protected override void DoClean() { if (_databaseFile.Exists()) { _databaseFile.Delete(); } } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutAllButNetworkingCS.cs000644 001750 001750 00000002237 11520622622 035322 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { /// /// Marker interface to denote that implementing test cases should be excluded /// from running with any fixture but a networking C/S one. /// /// /// Marker interface to denote that implementing test cases should be excluded /// from running with any fixture but a networking C/S one. /// public interface IOptOutAllButNetworkingCS : IOptOutSolo { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/IOptOutInMemory.cs000644 001750 001750 00000001500 11520622622 033447 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public interface IOptOutInMemory : IOptOutFromTestFixture { } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Fixtures/Db4oConsistencyCheckSolo.cs000644 001750 001750 00000006750 11520622622 035166 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4oUnit; using Db4oUnit.Extensions.Fixtures; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Consistency; using Db4objects.Db4o.Defragment; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; namespace Db4oUnit.Extensions.Fixtures { public class Db4oConsistencyCheckSolo : Db4oSolo { protected override IObjectContainer CreateDatabase(IConfiguration config) { Check(CloneConfig(config)); Defrag(CloneConfig(config)); Check(CloneConfig(config)); return base.CreateDatabase(config); } protected override void PreClose() { base.PreClose(); if (Db() != null && !Db().IsClosed()) { Db().Close(); } Check(CloneConfiguration()); Defrag(CloneConfiguration()); Check(CloneConfiguration()); } public override bool Accept(Type clazz) { return base.Accept(clazz) && !typeof(IOptOutDefragSolo).IsAssignableFrom(clazz); } private void Check(IConfiguration config) { IObjectContainer db = base.CreateDatabase(config); ConsistencyChecker.ConsistencyReport report = new ConsistencyChecker(db).CheckSlotConsistency (); CloseAndWait(db); if (!report.Consistent()) { throw new TestException(report.ToString(), null); } } private void Defrag(IConfiguration config) { Sharpen.IO.File origFile = new Sharpen.IO.File(GetAbsolutePath()); if (origFile.Exists()) { try { string backupFile = GetAbsolutePath() + ".defrag.backup"; IIdMapping mapping = new InMemoryIdMapping(); // new // BTreeIDMapping(getAbsolutePath()+".defrag.mapping",4096,1,1000); DefragmentConfig defragConfig = new DefragmentConfig(GetAbsolutePath(), backupFile , mapping); defragConfig.ForceBackupDelete(true); // FIXME Cloning is ugly - wrap original in Decorator within // DefragContext instead? IConfiguration clonedConfig = (IConfiguration)((IDeepClone)config).DeepClone(null ); defragConfig.Db4oConfig(clonedConfig); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig, new _IDefragmentListener_65 ()); } catch (IOException e) { Sharpen.Runtime.PrintStackTrace(e); } } } private sealed class _IDefragmentListener_65 : IDefragmentListener { public _IDefragmentListener_65() { } public void NotifyDefragmentInfo(DefragmentInfo info) { Sharpen.Runtime.Err.WriteLine(info); } } private IConfiguration CloneConfig(IConfiguration config) { return (IConfiguration)((IDeepClone)config).DeepClone(null); } private void CloseAndWait(IObjectContainer db) { db.Close(); try { ((ObjectContainerBase)db).ThreadPool().Join(3000); } catch (Exception) { } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutWorkspaceIssue.cs000644 001750 001750 00000001512 11520622622 033051 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public interface IOptOutWorkspaceIssue : IOptOutAndroid { //related to issue UNIT-31 } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ObjectSetAssert.cs000644 001750 001750 00000004122 11520622622 031662 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Db4o; using Db4objects.Db4o.Foundation; namespace Db4oUnit.Extensions { public class ObjectSetAssert { public static void SameContent(IObjectSet objectSet, object[] expectedItems) { Iterator4Assert.SameContent(Iterators.Iterate(expectedItems), Iterate(objectSet)); } public static void AreEqual(IObjectSet objectSet, object[] expectedItems) { Iterator4Assert.AreEqual(expectedItems, Iterate(objectSet)); } public static IEnumerator Iterate(IObjectSet objectSet) { return new ObjectSetAssert.ObjectSetIterator4(objectSet); } internal class ObjectSetIterator4 : IEnumerator { private static readonly object Invalid = new object(); private IObjectSet _objectSet; private object _current; public ObjectSetIterator4(IObjectSet collection) { _objectSet = collection; } public virtual object Current { get { if (_current == Invalid) { throw new InvalidOperationException(); } return _current; } } public virtual bool MoveNext() { if (_objectSet.HasNext()) { _current = _objectSet.Next(); return true; } _current = Invalid; return false; } public virtual void Reset() { _objectSet.Reset(); _current = Invalid; } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ComposibleTestSuite.cs000644 001750 001750 00000002501 11520622622 032563 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit.Extensions; using Sharpen; namespace Db4oUnit.Extensions { public abstract class ComposibleTestSuite : Db4oTestSuite { protected Type[] ComposeTests(Type[] testCases) { return Concat(testCases, ComposeWith()); } protected virtual Type[] ComposeWith() { return new Type[0]; } public static Type[] Concat(Type[] testCases, Type[] otherTests) { Type[] result = new Type[otherTests.Length + testCases.Length]; System.Array.Copy(testCases, 0, result, 0, testCases.Length); System.Array.Copy(otherTests, 0, result, testCases.Length, otherTests.Length); return result; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IDb4oTestCase.cs000644 001750 001750 00000001424 11520622622 031155 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; namespace Db4oUnit.Extensions { public interface IDb4oTestCase : ITestCase { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IDb4oFixture.cs000644 001750 001750 00000003160 11520622622 031067 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit.Extensions; using Db4oUnit.Fixtures; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; namespace Db4oUnit.Extensions { public interface IDb4oFixture : ILabeled { /// void Open(IDb4oTestCase testInstance); /// void Close(); /// void Reopen(IDb4oTestCase testInstance); void Clean(); LocalObjectContainer FileSession(); IExtObjectContainer Db(); IConfiguration Config(); bool Accept(Type clazz); /// void Defragment(); void ConfigureAtRuntime(IRuntimeConfigureAction action); void FixtureConfiguration(IFixtureConfiguration configuration); void ResetConfig(); IList UncaughtExceptions(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutVerySlow.cs000644 001750 001750 00000001477 11520622622 031706 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public interface IOptOutVerySlow : IOptOutAndroid { // related to UNIT-35 } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutExcludingClassLoaderIssue.cs000644 001750 001750 00000001526 11520622622 035100 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public interface IOptOutExcludingClassLoaderIssue : IOptOutAndroid { // related to issue UNIT-34 } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ISlotListener.cs000644 001750 001750 00000001523 11520622622 031360 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Internal.Slots; namespace Db4oUnit.Extensions { /// public interface ISlotListener { void OnFree(Slot slot); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Util/000755 001750 001750 00000000000 11520622064 027205 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Util/Binary.cs000644 001750 001750 00000002327 11520622622 030764 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4oUnit.Extensions.Util { /// public class Binary { public static long LongForBits(long bits) { return (long)((Math.Pow(2, bits)) - 1); } public static int NumberOfBits(long l) { if (l < 0) { throw new ArgumentException(); } long bit = 1; int counter = 0; for (int i = 0; i < 64; i++) { if ((l & bit) == 0) { counter++; } else { counter = 0; } bit = bit << 1; } return 64 - counter; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Util/CrossPlatformServices.cs000644 001750 001750 00000002771 11520622622 034045 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; using Db4objects.Db4o.Foundation.IO; using Db4objects.Db4o.Internal; using Sharpen; namespace Db4oUnit.Extensions.Util { public class CrossPlatformServices { public static string SimpleName(string typeName) { int index = typeName.IndexOf(','); if (index < 0) { return typeName; } return Sharpen.Runtime.Substring(typeName, 0, index); } public static string FullyQualifiedName(Type klass) { return ReflectPlatform.FullyQualifiedName(klass); } public static string DatabasePath(string fileName) { string path = Runtime.GetProperty("db4ounit.file.path"); if (path == null || path.Length == 0) { path = "."; } else { System.IO.Directory.CreateDirectory(path); } return Path.Combine(path, fileName); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Util/IOUtil.cs000644 001750 001750 00000002464 11520622622 030707 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.IO; using Db4objects.Db4o.Foundation.IO; namespace Db4oUnit.Extensions.Util { /// public class IOUtil { /// Deletes the directory /// public static void DeleteDir(string dir) { string absolutePath = new Sharpen.IO.File(dir).GetCanonicalPath(); Sharpen.IO.File fDir = new Sharpen.IO.File(dir); if (fDir.IsDirectory()) { string[] files = fDir.List(); for (int i = 0; i < files.Length; i++) { DeleteDir(Path.Combine(absolutePath, files[i])); } } File4.Delete(dir); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/TAFixtureConfiguration.cs000644 001750 001750 00000002661 11520622622 033227 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o.Config; using Db4objects.Db4o.TA; namespace Db4oUnit.Extensions { /// /// Configure the test case to run with TransparentActivationSupport /// enabled unless the test case implements OptOutTA. /// /// /// Configure the test case to run with TransparentActivationSupport /// enabled unless the test case implements OptOutTA. /// public class TAFixtureConfiguration : IFixtureConfiguration { public virtual void Configure(IDb4oTestCase testCase, IConfiguration config) { if (testCase is IOptOutTA) { return; } config.Add(new TransparentActivationSupport()); } public virtual string GetLabel() { return "TA"; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oFixtureVariable.cs000644 001750 001750 00000002045 11520622622 032425 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4oUnit.Fixtures; namespace Db4oUnit.Extensions { public sealed class Db4oFixtureVariable { public static readonly FixtureVariable FixtureVariable = new FixtureVariable("db4o" ); public static IDb4oFixture Fixture() { return (IDb4oFixture)FixtureVariable.Value; } private Db4oFixtureVariable() { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IRuntimeConfigureAction.cs000644 001750 001750 00000001506 11520622622 033355 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Config; namespace Db4oUnit.Extensions { public interface IRuntimeConfigureAction { void Apply(IConfiguration config); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/FreespaceManagerForDebug.cs000644 001750 001750 00000004755 11520622622 033440 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Freespace; using Db4objects.Db4o.Internal.Slots; namespace Db4oUnit.Extensions { public class FreespaceManagerForDebug : IFreespaceManager { private readonly ISlotListener _listener; public FreespaceManagerForDebug(ISlotListener listener) { _listener = listener; } public virtual Slot AllocateSafeSlot(int length) { return null; } public virtual void FreeSafeSlot(Slot slot) { } public virtual void BeginCommit() { } public virtual void Commit() { } public virtual void EndCommit() { } public virtual int SlotCount() { return 0; } public virtual void Free(Slot slot) { _listener.OnFree(slot); } public virtual void FreeSelf() { } public virtual Slot AllocateSlot(int length) { return null; } public virtual void Start(int id) { } public virtual byte SystemType() { return AbstractFreespaceManager.FmDebug; } public virtual void Traverse(IVisitor4 visitor) { } public virtual void Write(LocalObjectContainer container) { } public virtual void Listener(IFreespaceListener listener) { } public virtual void MigrateTo(IFreespaceManager fm) { } // TODO Auto-generated method stub public virtual int TotalFreespace() { // TODO Auto-generated method stub return 0; } public virtual void SlotFreed(Slot slot) { } // TODO Auto-generated method stub public virtual bool IsStarted() { return false; } public virtual Slot AllocateTransactionLogSlot(int length) { return null; } public virtual void Read(LocalObjectContainer container, Slot slot) { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ContainerServices.cs000644 001750 001750 00000002047 11520622622 032250 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; using Db4objects.Db4o; namespace Db4oUnit.Extensions { public class ContainerServices { /// public static void WithContainer(IObjectContainer container, IContainerBlock block ) { try { block.Run(container); } finally { container.Close(); } } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oConcurrencyTestSuite.cs000644 001750 001750 00000002173 11520622622 033477 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Concurrency; namespace Db4oUnit.Extensions { public abstract class Db4oConcurrencyTestSuite : AbstractDb4oTestCase, ITestSuiteBuilder { public virtual IEnumerator GetEnumerator() { return new Db4oConcurrencyTestSuiteBuilder(Fixture(), TestCases()).GetEnumerator( ); } protected abstract override Type[] TestCases(); } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutNotSupportedJavaxManagement.cs000644 001750 001750 00000001471 11520622622 035464 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public interface IOptOutNotSupportedJavaxManagement : IOptOutAndroid { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Concurrency/000755 001750 001750 00000000000 11520622056 030563 5ustar00directhexdirecthex000000 000000 src/Db4oUnit.Extensions/Db4oUnit.Extensions/Concurrency/ConcurrencyConventions.cs000644 001750 001750 00000002510 11520622622 035550 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions.Concurrency { public class ConcurrencyConventions { internal static string CheckMethodNameFor(string testMethodName) { int testPrefixLength = TestPrefix().Length; string subMethodName = Sharpen.Runtime.Substring(testMethodName, testPrefixLength ); return CheckPrefix() + subMethodName; } private static string CheckPrefix() { if (Db4oUnitPlatform.IsPascalCase()) { return "Check"; } return "check"; } public static string TestPrefix() { if (Db4oUnitPlatform.IsPascalCase()) { return "Conc"; } return "conc"; } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Concurrency/Db4oConcurrencyTestSuiteBuilder.cs000644 001750 001750 00000003765 11520622622 037231 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Concurrency; using Db4objects.Db4o.Ext; namespace Db4oUnit.Extensions.Concurrency { public class Db4oConcurrencyTestSuiteBuilder : Db4oTestSuiteBuilder { public Db4oConcurrencyTestSuiteBuilder(IDb4oFixture fixture, Type clazz) : base(fixture , clazz) { } public Db4oConcurrencyTestSuiteBuilder(IDb4oFixture fixture, Type[] classes) : base (fixture, classes) { } protected override ITest CreateTest(object instance, MethodInfo method) { return new ConcurrencyTestMethod(instance, method); } protected override bool IsTestMethod(MethodInfo method) { string name = method.Name; return StartsWithIgnoreCase(name, ConcurrencyConventions.TestPrefix()) && TestPlatform .IsPublic(method) && !TestPlatform.IsStatic(method) && HasValidParameter(method); } internal static bool HasValidParameter(MethodInfo method) { Type[] parameters = Sharpen.Runtime.GetParameterTypes(method); if (parameters.Length == 1 && parameters[0] == typeof(IExtObjectContainer)) { return true; } if (parameters.Length == 2 && parameters[0] == typeof(IExtObjectContainer) && parameters [1] == typeof(int)) { return true; } return false; } } } src/Db4oUnit.Extensions/Db4oUnit.Extensions/Concurrency/ConcurrencyTestMethod.cs000644 001750 001750 00000012503 11520622622 035326 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Concurrency; using Db4oUnit.Extensions.Fixtures; using Db4oUnit.Fixtures; using Db4objects.Db4o.Ext; using Sharpen.Lang; namespace Db4oUnit.Extensions.Concurrency { public class ConcurrencyTestMethod : TestMethod { private Thread[] threads; internal Exception[] failures; public ConcurrencyTestMethod(object instance, MethodInfo method) : base(instance, method) { } /// protected override void Invoke() { AbstractDb4oTestCase toTest = Subject(); MethodInfo method = GetMethod(); InvokeConcurrencyMethod(toTest, method); } private AbstractDb4oTestCase Subject() { return (AbstractDb4oTestCase)GetSubject(); } /// private void InvokeConcurrencyMethod(AbstractDb4oTestCase toTest, MethodInfo method ) { Type[] parameters = Sharpen.Runtime.GetParameterTypes(method); bool hasSequenceParameter = false; if (parameters.Length == 2) { // ExtObjectContainer, seq hasSequenceParameter = true; } int threadCount = toTest.ThreadCount(); threads = new Thread[threadCount]; failures = new Exception[threadCount]; for (int i = 0; i < threadCount; ++i) { threads[i] = new Thread(new ConcurrencyTestMethod.RunnableTestMethod(this, toTest , method, i, hasSequenceParameter), "ConcurrencyTestMethod.invokeConcurrencyMethod Thread[" + i + "]"); } // start threads simultaneously for (int i = 0; i < threadCount; ++i) { threads[i].Start(); } // wait for the threads to end for (int i = 0; i < threadCount; ++i) { threads[i].Join(); } // check if any of the threads ended abnormally for (int i = 0; i < threadCount; ++i) { if (failures[i] != null) { // TODO: show all failures by throwing another kind of exception. throw failures[i]; } } // check test result CheckConcurrencyMethod(toTest, method.Name); } /// private void CheckConcurrencyMethod(AbstractDb4oTestCase toTest, string testMethodName ) { MethodInfo checkMethod = CheckMethodFor(toTest.GetType(), testMethodName); if (null == checkMethod) { return; } // pass ExtObjectContainer as a param to check method IExtObjectContainer oc = Fixture().Db(); try { checkMethod.Invoke(toTest, new object[] { oc }); } finally { oc.Close(); } } private MethodInfo CheckMethodFor(Type testClass, string testMethodName) { try { Type[] types = new Type[] { typeof(IExtObjectContainer) }; return Sharpen.Runtime.GetDeclaredMethod(testClass, ConcurrencyConventions.CheckMethodNameFor (testMethodName), types); } catch (Exception) { // if checkMethod is not availble, return as success return null; } } internal class RunnableTestMethod : Contextful, IRunnable { private AbstractDb4oTestCase toTest; private MethodInfo method; private int seq; private bool showSeq; internal RunnableTestMethod(ConcurrencyTestMethod _enclosing, AbstractDb4oTestCase toTest, MethodInfo method, int seq, bool showSeq) { this._enclosing = _enclosing; this.toTest = toTest; this.method = method; this.seq = seq; this.showSeq = showSeq; } public virtual void Run() { this.Run(new _IRunnable_115(this)); } private sealed class _IRunnable_115 : IRunnable { public _IRunnable_115(RunnableTestMethod _enclosing) { this._enclosing = _enclosing; } public void Run() { this._enclosing.RunMethod(); } private readonly RunnableTestMethod _enclosing; } internal virtual void RunMethod() { IExtObjectContainer oc = null; try { oc = this._enclosing.Fixture().OpenNewSession(this.toTest); object[] args; if (this.showSeq) { args = new object[2]; args[0] = oc; args[1] = this.seq; } else { args = new object[1]; args[0] = oc; } this.method.Invoke(this.toTest, args); } catch (Exception e) { this._enclosing.failures[this.seq] = e; } finally { if (oc != null) { oc.Close(); } } } private readonly ConcurrencyTestMethod _enclosing; } internal virtual IMultiSessionFixture Fixture() { return ((IMultiSessionFixture)AbstractDb4oTestCase.Fixture()); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutTA.cs000644 001750 001750 00000001615 11520622622 030412 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4oUnit.Extensions { /// /// Marks a test case as non valid for the /// TAFixtureConfiguration /// . /// public interface IOptOutTA { } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/ExpectingVisitor.cs000644 001750 001750 00000010145 11520622622 032126 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit; using Db4oUnit.Extensions; using Db4objects.Db4o.Foundation; using Sharpen; namespace Db4oUnit.Extensions { public class ExpectingVisitor : IVisitor4 { private const bool Debug = false; private readonly object[] _expected; private readonly bool _obeyOrder; private readonly Collection4 _unexpected = new Collection4(); private bool _ignoreUnexpected; private int _cursor; private sealed class _object_24 : object { public _object_24() { } public override string ToString() { return "[FOUND]"; } } private static readonly object Found = new _object_24(); public ExpectingVisitor(object[] results, bool obeyOrder, bool ignoreUnexpected) { _expected = new object[results.Length]; System.Array.Copy(results, 0, _expected, 0, results.Length); _obeyOrder = obeyOrder; _ignoreUnexpected = ignoreUnexpected; } public ExpectingVisitor(object[] results) : this(results, false, false) { } public ExpectingVisitor(object singleObject) : this(new object[] { singleObject } ) { } /// Expect empty public ExpectingVisitor() : this(new object[0]) { } public virtual void Visit(object obj) { if (_obeyOrder) { VisitOrdered(obj); } else { VisitUnOrdered(obj); } } private void VisitOrdered(object obj) { if (_cursor < _expected.Length) { if (AreEqual(_expected[_cursor], obj)) { Ods("Expected OK: " + obj.ToString()); _expected[_cursor] = Found; _cursor++; return; } } Unexpected(obj); } private void Unexpected(object obj) { if (_ignoreUnexpected) { return; } _unexpected.Add(obj); Ods("Unexpected: " + obj); } private void VisitUnOrdered(object obj) { for (int i = 0; i < _expected.Length; i++) { object expectedItem = _expected[i]; if (AreEqual(obj, expectedItem)) { Ods("Expected OK: " + obj); _expected[i] = Found; return; } } Unexpected(obj); } private bool AreEqual(object obj, object expectedItem) { return expectedItem == obj || (expectedItem != null && obj != null && expectedItem .Equals(obj)); } private static void Ods(string message) { } public virtual void AssertExpectations() { if (_unexpected.Size() > 0) { Assert.Fail("UNEXPECTED: " + _unexpected.ToString()); } for (int i = 0; i < _expected.Length; i++) { Assert.AreSame(Found, _expected[i]); } } public static Db4oUnit.Extensions.ExpectingVisitor CreateExpectingVisitor(int value , int count) { int[] values = new int[count]; for (int i = 0; i < values.Length; i++) { values[i] = value; } return new Db4oUnit.Extensions.ExpectingVisitor(IntArrays4.ToObjectArray(values)); } public static Db4oUnit.Extensions.ExpectingVisitor CreateExpectingVisitor(int[] keys ) { return new Db4oUnit.Extensions.ExpectingVisitor(IntArrays4.ToObjectArray(keys)); } public static Db4oUnit.Extensions.ExpectingVisitor CreateSortedExpectingVisitor(int [] keys) { return new Db4oUnit.Extensions.ExpectingVisitor(IntArrays4.ToObjectArray(keys), true , false); } public static Db4oUnit.Extensions.ExpectingVisitor CreateExpectingVisitor(int expectedID ) { return CreateExpectingVisitor(expectedID, 1); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IOptOutBigMathIssue.cs000644 001750 001750 00000001512 11520622622 032426 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { public interface IOptOutBigMathIssue : IOptOutAndroid { // related to issue COR-2007 } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/FieldIndexAssert.cs000644 001750 001750 00000004337 11520622622 032023 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4oUnit; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal; using Db4objects.Db4o.Internal.Btree; namespace Db4oUnit.Extensions { public class FieldIndexAssert { private readonly Type _clazz; private readonly string _name; public FieldIndexAssert(Type clazz, string name) { _clazz = clazz; _name = name; } public virtual void AssertSingleEntry(LocalObjectContainer container, long id) { BooleanByRef called = new BooleanByRef(); Index(container).TraverseKeys(container.SystemTransaction(), new _IVisitor4_24(id , called)); Assert.IsTrue(called.value); } private sealed class _IVisitor4_24 : IVisitor4 { public _IVisitor4_24(long id, BooleanByRef called) { this.id = id; this.called = called; } public void Visit(object key) { Assert.AreEqual(id, ((IFieldIndexKey)key).ParentID()); Assert.IsFalse(called.value); called.value = true; } private readonly long id; private readonly BooleanByRef called; } private BTree Index(LocalObjectContainer container) { return FieldMetadata(container).GetIndex(null); } private Db4objects.Db4o.Internal.FieldMetadata FieldMetadata(LocalObjectContainer container) { return ClassMetadata(container).FieldMetadataForName(_name); } private Db4objects.Db4o.Internal.ClassMetadata ClassMetadata(LocalObjectContainer container) { return container.ClassMetadataForReflectClass(container.Reflector().ForClass(_clazz )); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Dbmock/000755 001750 001750 00000000000 11520622070 027464 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Dbmock/MockClient.cs000644 001750 001750 00000022426 11520622622 032054 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.IO; using Db4objects.Db4o.Qlin; using Db4objects.Db4o.Query; using Db4objects.Db4o.Reflect; using Db4objects.Db4o.Reflect.Generic; namespace Db4oUnit.Extensions.Dbmock { public partial class MockClient : IExtClient { public virtual bool IsAlive() { throw new NotImplementedException(); } public virtual void SwitchToFile(string fileName) { throw new NotImplementedException(); } public virtual void SwitchToMainFile() { throw new NotImplementedException(); } /// /// public virtual void Activate(object obj) { throw new NotImplementedException(); } /// /// /// public virtual void Backup(string path) { throw new NotImplementedException(); } /// /// /// public virtual void Backup(IStorage targetStorage, string path) { throw new NotImplementedException(); } /// /// public virtual void Bind(object obj, long id) { throw new NotImplementedException(); } public virtual IConfiguration Configure() { throw new NotImplementedException(); } public virtual void Deactivate(object obj) { throw new NotImplementedException(); } public virtual object Descend(object obj, string[] path) { throw new NotImplementedException(); } /// /// public virtual object GetByID(long Id) { throw new NotImplementedException(); } /// /// public virtual object GetByUUID(Db4oUUID uuid) { throw new NotImplementedException(); } public virtual long GetID(object obj) { throw new NotImplementedException(); } public virtual IObjectInfo GetObjectInfo(object obj) { throw new NotImplementedException(); } public virtual Db4oDatabase Identity() { throw new NotImplementedException(); } public virtual bool IsActive(object obj) { throw new NotImplementedException(); } public virtual bool IsCached(long Id) { throw new NotImplementedException(); } public virtual bool IsClosed() { throw new NotImplementedException(); } /// public virtual bool IsStored(object obj) { throw new NotImplementedException(); } public virtual IReflectClass[] KnownClasses() { throw new NotImplementedException(); } public virtual object Lock() { throw new NotImplementedException(); } public virtual object PeekPersisted(object @object, int depth, bool committed) { throw new NotImplementedException(); } public virtual void Purge() { throw new NotImplementedException(); } public virtual void Purge(object obj) { throw new NotImplementedException(); } public virtual GenericReflector Reflector() { throw new NotImplementedException(); } public virtual void Refresh(object obj, int depth) { throw new NotImplementedException(); } public virtual void ReleaseSemaphore(string name) { throw new NotImplementedException(); } public virtual bool SetSemaphore(string name, int waitForAvailability) { throw new NotImplementedException(); } public virtual void Store(object obj, int depth) { throw new NotImplementedException(); } public virtual IStoredClass StoredClass(object clazz) { throw new NotImplementedException(); } public virtual IStoredClass[] StoredClasses() { throw new NotImplementedException(); } public virtual ISystemInfo SystemInfo() { throw new NotImplementedException(); } public virtual long Version() { throw new NotImplementedException(); } /// /// public virtual void Activate(object obj, int depth) { throw new NotImplementedException(); } /// public virtual bool Close() { throw new NotImplementedException(); } /// /// /// public virtual void Commit() { throw new NotImplementedException(); } /// public virtual void Deactivate(object obj, int depth) { throw new NotImplementedException(); } /// /// /// public virtual void Delete(object obj) { throw new NotImplementedException(); } public virtual IExtObjectContainer Ext() { throw new NotImplementedException(); } /// /// public virtual IObjectSet Get(object template) { throw new NotImplementedException(); } /// public virtual IQuery Query() { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Type clazz) { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Predicate predicate) { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Predicate predicate, IQueryComparator comparator) { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Predicate predicate, IComparer comparator) { throw new NotImplementedException(); } /// /// public virtual IObjectSet QueryByExample(object template) { throw new NotImplementedException(); } /// /// /// public virtual void Rollback() { throw new NotImplementedException(); } /// /// public virtual void Store(object obj) { throw new NotImplementedException(); } public virtual IObjectContainer OpenSession() { throw new NotImplementedException(); } public virtual IQLin From(Type clazz) { throw new NotImplementedException(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Dbmock/MockEmbedded.cs000644 001750 001750 00000012143 11520622622 032322 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4objects.Db4o; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Qlin; using Db4objects.Db4o.Query; namespace Db4oUnit.Extensions.Dbmock { public partial class MockEmbedded : IEmbeddedObjectContainer { /// /// /// public virtual void Backup(string path) { throw new NotImplementedException(); } public virtual IObjectContainer OpenSession() { throw new NotImplementedException(); } /// /// public virtual void Activate(object obj, int depth) { throw new NotImplementedException(); } /// public virtual bool Close() { throw new NotImplementedException(); } /// /// /// public virtual void Commit() { throw new NotImplementedException(); } /// public virtual void Deactivate(object obj, int depth) { throw new NotImplementedException(); } /// /// /// public virtual void Delete(object obj) { throw new NotImplementedException(); } public virtual IExtObjectContainer Ext() { throw new NotImplementedException(); } /// /// public virtual IObjectSet Get(object template) { throw new NotImplementedException(); } /// public virtual IQuery Query() { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Type clazz) { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Predicate predicate) { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Predicate predicate, IQueryComparator comparator) { throw new NotImplementedException(); } /// /// public virtual IObjectSet Query(Predicate predicate, IComparer comparator) { throw new NotImplementedException(); } /// /// public virtual IObjectSet QueryByExample(object template) { throw new NotImplementedException(); } /// /// /// public virtual void Rollback() { throw new NotImplementedException(); } /// /// public virtual void Store(object obj) { throw new NotImplementedException(); } public virtual IQLin From(Type clazz) { throw new NotImplementedException(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Dbmock/MockServer.cs000644 001750 001750 00000002341 11520622622 032076 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o; using Db4objects.Db4o.Ext; namespace Db4oUnit.Extensions.Dbmock { public partial class MockServer : IObjectServer { public virtual bool Close() { throw new NotImplementedException(); } public virtual IExtObjectServer Ext() { throw new NotImplementedException(); } public virtual void GrantAccess(string userName, string password) { throw new NotImplementedException(); } public virtual IObjectContainer OpenClient() { throw new NotImplementedException(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/IntArrays4.cs000644 001750 001750 00000003617 11520622622 030626 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using Db4objects.Db4o.Foundation; using Sharpen; namespace Db4oUnit.Extensions { public class IntArrays4 { public static int[] Fill(int[] array, int value) { for (int i = 0; i < array.Length; ++i) { array[i] = value; } return array; } public static int[] Concat(int[] a, int[] b) { int[] array = new int[a.Length + b.Length]; System.Array.Copy(a, 0, array, 0, a.Length); System.Array.Copy(b, 0, array, a.Length, b.Length); return array; } public static int Occurences(int[] values, int value) { int count = 0; for (int i = 0; i < values.Length; i++) { if (values[i] == value) { count++; } } return count; } public static int[] Clone(int[] bars) { int[] array = new int[bars.Length]; System.Array.Copy(bars, 0, array, 0, bars.Length); return array; } public static object[] ToObjectArray(int[] values) { object[] ret = new object[values.Length]; for (int i = 0; i < values.Length; i++) { ret[i] = values[i]; } return ret; } public static IEnumerator NewIterator(int[] values) { return new ArrayIterator4(ToObjectArray(values)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions/Db4oTestSuite.cs000644 001750 001750 00000002473 11520622622 031267 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using Db4oUnit; using Db4oUnit.Extensions; namespace Db4oUnit.Extensions { /// Base class for composable db4o test suites (AllTests classes inside each package, for instance). /// /// Base class for composable db4o test suites (AllTests classes inside each package, for instance). /// public abstract class Db4oTestSuite : AbstractDb4oTestCase, ITestSuiteBuilder { public virtual IEnumerator GetEnumerator() { return new Db4oTestSuiteBuilder(Fixture(), TestCases()).GetEnumerator(); } protected abstract override Type[] TestCases(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/000755 001750 001750 00000000000 11520622040 023762 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/000755 001750 001750 00000000000 11520622064 027556 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/AbstractDb4oTestCase.cs000644 001750 001750 00000002024 11520622622 034013 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Config; using Db4objects.Db4o.IO; namespace Db4oUnit.Extensions { /// /// Additional helper methods to make it easier to create /// test cases in c#. /// public partial class AbstractDb4oTestCase { protected T RetrieveOnlyInstance() { return (T) RetrieveOnlyInstance(typeof(T)); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Fixtures/000755 001750 001750 00000000000 11520622070 031364 5ustar00directhexdirecthex000000 000000 src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Fixtures/SilverlightFixture.cs000644 001750 001750 00000003640 11520622622 035505 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if SILVERLIGHT using Db4objects.Db4o; using Db4objects.Db4o.Config; using Db4objects.Db4o.Internal.Config; using Db4objects.Db4o.IO; namespace Db4oUnit.Extensions.Fixtures { public class SilverlightFixture : AbstractSoloDb4oFixture { protected override void DoClean() { if (null != _storage) { _storage.Delete(DatabaseFileName); } } public override string Label() { return BuildLabel("Silverlight Solo"); } public override void Defragment() { Defragment(DatabaseFileName); } protected override IObjectContainer CreateDatabase(IConfiguration config) { _storage = config.Storage; return Db4oFactory.OpenFile(config, DatabaseFileName); } protected override IConfiguration NewConfiguration() { var config = base.NewConfiguration(); var embeddedConfig = new EmbeddedConfigurationImpl(config); embeddedConfig.AddConfigurationItem(new SilverlightSupport()); return config; } public override bool Accept(System.Type clazz) { if (typeof(IOptOutSilverlight).IsAssignableFrom(clazz)) return false; return base.Accept(clazz); } private const string DatabaseFileName = "SilverlightDatabase.db4o"; private IStorage _storage; } } #endifsrc/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Fixtures/Db4oNetworking.cs000644 001750 001750 00000005141 11520622622 034500 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if SILVERLIGHT using System; using System.Collections; using Db4objects.Db4o.Config; using Db4objects.Db4o.Ext; using Db4objects.Db4o.Internal; using Db4oUnit.Fixtures; namespace Db4oUnit.Extensions.Fixtures { public class Db4oNetworking : IMultiSessionFixture { public Db4oNetworking() { throw new NotImplementedException(); } public Db4oNetworking(string label) { throw new NotImplementedException(); } string ILabeled.Label() { throw new NotImplementedException(); } void IDb4oFixture.Open(IDb4oTestCase testInstance) { throw new NotImplementedException(); } void IDb4oFixture.Close() { throw new NotImplementedException(); } void IDb4oFixture.Reopen(IDb4oTestCase testInstance) { throw new NotImplementedException(); } void IDb4oFixture.Clean() { throw new NotImplementedException(); } LocalObjectContainer IDb4oFixture.FileSession() { throw new NotImplementedException(); } IExtObjectContainer IDb4oFixture.Db() { throw new NotImplementedException(); } IConfiguration IDb4oFixture.Config() { throw new NotImplementedException(); } bool IDb4oFixture.Accept(Type clazz) { throw new NotImplementedException(); } void IDb4oFixture.Defragment() { throw new NotImplementedException(); } void IDb4oFixture.ConfigureAtRuntime(IRuntimeConfigureAction action) { throw new NotImplementedException(); } void IDb4oFixture.FixtureConfiguration(IFixtureConfiguration configuration) { throw new NotImplementedException(); } void IDb4oFixture.ResetConfig() { throw new NotImplementedException(); } IList IDb4oFixture.UncaughtExceptions() { throw new NotImplementedException(); } IExtObjectContainer IMultiSessionFixture.OpenNewSession(IDb4oTestCase testInstance) { throw new NotImplementedException(); } } } #endifdb4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Util/000755 001750 001750 00000000000 11520622064 030473 5ustar00directhexdirecthex000000 000000 src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Util/DiagnosticCollector.cs000644 001750 001750 00000002701 11520622622 034676 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections.Generic; using System.Text; using Db4objects.Db4o.Diagnostic; namespace Db4oUnit.Extensions.Util { public class DiagnosticCollector : IDiagnosticListener { public void OnDiagnostic(IDiagnostic d) { if (typeof(T) == d.GetType()) { _diagnostics.Add(d); } } public IList Diagnostics { get { return _diagnostics; } } public bool Empty { get { return _diagnostics.Count == 0; } } public override string ToString() { StringBuilder sb = new StringBuilder(); foreach (IDiagnostic diagnostic in _diagnostics) { sb.Append(diagnostic + "\r\n"); } return sb.ToString(); } private readonly IList _diagnostics = new List(); } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Util/IOServices.cs000644 001750 001750 00000007244 11520622622 033044 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Diagnostics; using System.IO; using System.Text; namespace Db4oUnit.Extensions.Util { public class IOServices { public static string FindParentDirectory(string path) { #if !CF string parent = Path.GetFullPath(".."); while (true) { if (Directory.Exists(Path.Combine(parent, path))) return parent; string oldParent = parent; parent = Path.GetDirectoryName(parent); if (parent == oldParent || parent == null) break; } #endif return null; } public static void WriteFile(string fname, string contents) { CreateParentDirectories(fname); using (StreamWriter writer = new StreamWriter(fname)) { writer.Write(contents); } } private static void CreateParentDirectories(string fname) { Directory.CreateDirectory(Path.GetDirectoryName(fname)); } public static string JoinQuotedArgs(string[] args) { return JoinQuotedArgs(' ', args); } public static string JoinQuotedArgs(char separator, params string[] args) { StringBuilder builder = new StringBuilder(); foreach (string arg in args) { if (builder.Length > 0) builder.Append(separator); builder.Append(Quote(arg)); } return builder.ToString(); } public static string Quote(string s) { if (s.StartsWith("\"")) return s; return "\"" + s + "\""; } #if !CF && !SILVERLIGHT public static string Exec(string program, params string[] arguments) { return Exec(program, JoinQuotedArgs(arguments)); } private static string Exec(string program, string arguments) { ProcessStartInfo psi = new ProcessStartInfo(program); psi.UseShellExecute = false; psi.Arguments = arguments; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.WorkingDirectory = Path.GetTempPath(); psi.CreateNoWindow = true; Process p = Process.Start(psi); string stdout = p.StandardOutput.ReadToEnd(); string stderr = p.StandardError.ReadToEnd(); p.WaitForExit(); if (p.ExitCode != 0) throw new ApplicationException(stdout + stderr); return stdout + stderr; } public static string CopyEnclosingAssemblyTo(Type type, string directory) { return CopyTo(type.Assembly.Location, directory); } #endif public static string BuildTempPath(string fname) { #if SILVERLIGHT return "/temp" + DateTime.Now.Ticks + "/" + fname; #elif !CF && !MONO return Path.Combine(Environment.GetEnvironmentVariable("TEMP"), fname); #else return Path.Combine(Path.GetTempPath(), fname); #endif } public static string CopyTo(string fname, string targetDirectory) { Directory.CreateDirectory(targetDirectory); string targetFileName = Path.Combine(targetDirectory, Path.GetFileName(fname)); File.Copy(fname, targetFileName, true); return targetFileName; } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Dbmock/000755 001750 001750 00000000000 11520622070 030752 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Dbmock/MockClient.cs000644 001750 001750 00000003356 11520622622 033343 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; namespace Db4oUnit.Extensions.Dbmock { public partial class MockClient : IDisposable { public virtual void Dispose() { } public virtual IList Query(Predicate match) { throw new System.NotImplementedException(); } public virtual IList Query(Predicate match, IComparer comparer) { throw new System.NotImplementedException(); } public virtual IList Query(Predicate match, Comparison comparison) { throw new System.NotImplementedException(); } public virtual IList Query(Type extent) { throw new System.NotImplementedException(); } public virtual IList Query() { throw new System.NotImplementedException(); } public virtual IList Query(IComparer comparer) { throw new System.NotImplementedException(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Dbmock/MockEmbedded.cs000644 001750 001750 00000003267 11520622622 033617 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; namespace Db4oUnit.Extensions.Dbmock { public partial class MockEmbedded : IDisposable { public void Dispose() { } public IList Query(Predicate match) { throw new System.NotImplementedException(); } public IList Query(Predicate match, IComparer comparer) { throw new System.NotImplementedException(); } public IList Query(Predicate match, Comparison comparison) { throw new System.NotImplementedException(); } public IList Query(Type extent) { throw new System.NotImplementedException(); } public IList Query() { throw new System.NotImplementedException(); } public IList Query(IComparer comparer) { throw new System.NotImplementedException(); } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Dbmock/MockServer.cs000644 001750 001750 00000001461 11520622622 033366 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4oUnit.Extensions.Dbmock { public partial class MockServer : IDisposable { public void Dispose() { } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/native/Db4oUnit.Extensions/Db4oUnitPlatform.cs000644 001750 001750 00000002465 11520622622 033251 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using Db4objects.Db4o.IO; using Db4objects.Db4o.Reflect.Net; namespace Db4oUnit.Extensions { public class Db4oUnitPlatform { public static bool IsPascalCase() { return true; } public static bool IsUserField(FieldInfo field) { if (field.IsStatic) return false; if (NetField.IsTransient(field)) return false; if (field.Name.IndexOf("$") != -1) return false; return true; } public static IStorage NewPersistentStorage() { #if SILVERLIGHT return new IsolatedStorageStorage(); #else return new FileStorage(); #endif } } } db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions-CF-2008.csproj000644 001750 001750 00000026600 11520622060 030367 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.21022 2.0 {6C7B5203-2178-4BFC-B8AB-D387D7C28A65} Library Properties Db4oUnit.Extensions Db4oUnit.Extensions {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 Db4oUnit.Extensions_CF_2008 v3.5 2.0 Pocket PC 2003 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;CF_3_5;CF;$(PlatformFamilyName) true true prompt 512 4 Off 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;CF_3_5;CF;$(PlatformFamilyName) true true prompt 512 4 Off 1591;1572;1573;1574;0419; {89BB3D10-B9D5-4172-A0D9-3BB856AC5B85} Db4objects.Db4o.CS-CF-2008 {667C616E-FEA2-4D5E-93F0-9D18D17275FA} Db4objects.Db4o.Optional-CF-2008 {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 {7C7F460A-A3A0-40D5-872C-B7BA617F9BA7} Db4oUnit-CF-2008 False C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\mscorlib.dll False C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.dll db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions-2008.csproj000644 001750 001750 00000025003 11520622052 030076 0ustar00directhexdirecthex000000 000000 9.0.21022 2.0 Debug AnyCPU Db4oUnit.Extensions Library Db4oUnit.Extensions OnBuildSuccess v3.5 512 {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3} true ../db4objects.snk bin\Debug\ false 285212672 false true TRACE;DEBUG;NET_3_5 4096 false 1591;1572;1573;1574;0419; false false false false 0 bin\Release\ false 285212672 false false TRACE;NET_3_5 4096 false 1591;1572;1573;1574;0419; true false false false 4 System {9FA8178A-3E77-42C5-A252-6690EA9BA257} Db4objects.Db4o.CS-2008 {E9588FE7-C19D-445E-BB53-AE539EA4F0E6} Db4objects.Db4o.Optional-2008 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 {8F82F8B0-95B6-4553-BDA8-BD9A954E682F} Db4oUnit-2008 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions-Silverlight-2008.csproj000644 001750 001750 00000024257 11520622042 032401 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {13B5E015-9250-4E70-939D-56233D43D8C3} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4oUnit.Extensions Db4oUnit.Extensions v3.5 false true true true ../db4objects.snk true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 {97B6DEA6-255B-4B49-8973-38943AC2E70C} Db4objects.Db4o.Optional-Silverlight-2008 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2008 {C74364D8-A04A-4CF9-801D-D1811D49E72A} Db4oUnit-Silverlight-2008 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Makefile000644 001750 001750 00000000171 11520622054 024140 0ustar00directhexdirecthex000000 000000 include ../include.mk TARGET = library ASSEMBLY = $(UNIT_EXT) REFERENCES = -r:$(OUTDIR)/$(UNIT) -r:$(OUTDIR)/$(CORE) db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Properties/000755 001750 001750 00000000000 11520622064 024636 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Properties/AssemblyInfo.cs000644 001750 001750 00000002576 11520622622 027572 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Security; [assembly: AssemblyTitle("db4o - database for objects")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyName("")] // attributes are automatically set by the build [assembly: AssemblyVersion("8.0.184.15484")] [assembly: AssemblyKeyFile("")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyDescription("Db4oUnit.Extensions 8.0.184.15484 (.NET)")]db4o-8.0.184.15484+dfsg/src/Db4oUnit.Extensions/Db4oUnit.Extensions-Silverlight-2010.csproj000644 001750 001750 00000025361 11520622044 032371 0ustar00directhexdirecthex000000 000000 v3.5 true ../db4objects.snk Debug AnyCPU 9.0.30729 2.0 {13B5E015-9250-4E70-939D-56233D43D8C3} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4oUnit.Extensions Db4oUnit.Extensions v4.0 false true true true ../db4objects.snk Silverlight $(TargetFrameworkVersion) 3.5 true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 {97B6DEA6-255B-4B49-8973-38943AC2E70C} Db4objects.Db4o.Optional-Silverlight-2010 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2010 {C74364D8-A04A-4CF9-801D-D1811D49E72A} Db4oUnit-Silverlight-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/000755 001750 001750 00000000000 11520622070 025454 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/WebBrowerHost.resx000644 001750 001750 00000013266 11520622070 031123 0ustar00directhexdirecthex000000 000000 text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 src/Db4objects.Db4o.SilverlightTestHost/Db4objects.Db4o.SilverlightTestHost.csproj000644 001750 001750 00000007241 11520622054 035370 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg Debug AnyCPU 9.0.30729 2.0 {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59} Exe Properties Db4objects.Db4o.SilverlightTestHost Db4objects.Db4o.SilverlightTestHost v3.5 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 x86 pdbonly true bin\Release\ TRACE prompt 4 true bin\x86\Debug\ DEBUG;TRACE full x86 prompt bin\x86\Release\ TRACE true pdbonly x86 prompt 3.5 3.5 3.5 Form WebBrowerHost.cs WebBrowerHost.cs db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/WebBrowerHost.Designer.cs000644 001750 001750 00000004677 11520622624 032321 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.SilverlightTestHost { partial class WebBrowerHost { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.silverlightTestHost = new System.Windows.Forms.WebBrowser(); this.SuspendLayout(); // // silverlightTestHost // this.silverlightTestHost.Dock = System.Windows.Forms.DockStyle.Fill; this.silverlightTestHost.Location = new System.Drawing.Point(0, 0); this.silverlightTestHost.MinimumSize = new System.Drawing.Size(20, 20); this.silverlightTestHost.Name = "silverlightTestHost"; this.silverlightTestHost.Size = new System.Drawing.Size(575, 525); this.silverlightTestHost.TabIndex = 0; // // WebBrowerHost // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(575, 525); this.Controls.Add(this.silverlightTestHost); this.Name = "WebBrowerHost"; this.Text = "WebBrowerHost"; this.ResumeLayout(false); } #endregion private System.Windows.Forms.WebBrowser silverlightTestHost; } }src/Db4objects.Db4o.SilverlightTestHost/Db4objects.Db4o.SilverlightTestHost-2010.csproj000644 001750 001750 00000007735 11520622066 035763 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg Debug AnyCPU 9.0.30729 2.0 {2E3829A5-D028-43BC-8ED5-14C0BE7A4A59} Exe Properties Db4objects.Db4o.SilverlightTestHost Db4objects.Db4o.SilverlightTestHost v4.0 512 3.5 true ../db4objects.snk true full false bin\Debug\ DEBUG;TRACE prompt 4 x86 pdbonly true bin\Release\ TRACE prompt 4 true bin\x86\Debug\ DEBUG;TRACE full x86 prompt bin\x86\Release\ TRACE true pdbonly x86 prompt 3.5 3.5 3.5 Form WebBrowerHost.cs WebBrowerHost.cs db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/Program.cs000644 001750 001750 00000002074 11520622624 027422 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO; namespace Db4objects.Db4o.SilverlightTestHost { class Program { [STAThread] static int Main(string[] args) { if (args.Length < 1) { Console.Error.WriteLine("Missing silverlight tests folder."); return -1; } WebBrowerHost host = new WebBrowerHost(); return host.Navigate(Path.Combine(args[0], "TestPage.html")); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/Properties/000755 001750 001750 00000000000 11520622052 027610 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/Properties/AssemblyInfo.cs000644 001750 001750 00000004333 11520622624 032542 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Db4objects.Db4o.SilverlightTestHost")] [assembly: AssemblyDescription("Db4objects.Db4o.SilverlightTestHost 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("acc20ef7-3dc8-47be-b98c-453d2b0d2a26")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("8.0.184.15484")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("8.0.184.15484")] db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.SilverlightTestHost/WebBrowerHost.cs000644 001750 001750 00000003551 11520622624 030550 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Threading; using System.Windows.Forms; using Timer=System.Threading.Timer; namespace Db4objects.Db4o.SilverlightTestHost { public partial class WebBrowerHost : Form { private string _url; private Timer _timer; public WebBrowerHost() { InitializeComponent(); } public int ErrorCount { get; set; } public int Navigate(string url) { _url = url; ShowDialog(); return ErrorCount; } protected override void OnHandleCreated(EventArgs e) { silverlightTestHost.Navigate(_url); _timer = new Timer(state => Invoke((ThreadStart) CheckTestsCompletion), null, 1000, 1000); } private void CheckTestsCompletion() { HtmlElement element = silverlightTestHost.Document.GetElementById("completed"); if (element != null) { _timer.Dispose(); string testResults = silverlightTestHost.Document.GetElementById("result").InnerText; ErrorCount = Int32.Parse(ErrorCountFromHtmlPage()); Console.Error.WriteLine(testResults); Close(); } } private string ErrorCountFromHtmlPage() { return silverlightTestHost.Document.InvokeScript("getErrorCount").ToString(); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/000755 001750 001750 00000000000 11520622070 022365 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq-2008.sln000644 001750 001750 00000005703 11520622064 027156 0ustar00directhexdirecthex000000 000000  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq-2008", "Db4objects.Db4o.Linq-2008.csproj", "{23531440-0922-43EB-A483-6592FFC2F093}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o.Linq.Tests-2008", "..\Db4objects.Db4o.Linq.Tests\Db4objects.Db4o.Linq.Tests-2008.csproj", "{22AB6F58-39BF-4580-821B-5900E31AC33A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4objects.Db4o-2008", "..\Db4objects.Db4o\Db4objects.Db4o-2008.csproj", "{600CD3BF-2ED2-4183-87F7-ADD78A968AE0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit-2008", "..\Db4oUnit\Db4oUnit-2008.csproj", "{8F82F8B0-95B6-4553-BDA8-BD9A954E682F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4oUnit.Extensions-2008", "..\Db4oUnit.Extensions\Db4oUnit.Extensions-2008.csproj", "{9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {23531440-0922-43EB-A483-6592FFC2F093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Debug|Any CPU.Build.0 = Debug|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Release|Any CPU.ActiveCfg = Release|Any CPU {23531440-0922-43EB-A483-6592FFC2F093}.Release|Any CPU.Build.0 = Release|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Debug|Any CPU.Build.0 = Debug|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Release|Any CPU.ActiveCfg = Release|Any CPU {22AB6F58-39BF-4580-821B-5900E31AC33A}.Release|Any CPU.Build.0 = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {600CD3BF-2ED2-4183-87F7-ADD78A968AE0}.Release|Any CPU.Build.0 = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F82F8B0-95B6-4553-BDA8-BD9A954E682F}.Release|Any CPU.Build.0 = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {9446B00C-E8A6-4CEB-83DE-2CAC5168DFE3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq-2010.csproj000644 001750 001750 00000017414 11520622070 027652 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {23531440-0922-43EB-A483-6592FFC2F093} Library Properties Db4objects.Db4o.Linq Db4objects.Db4o.Linq v4.0 512 3.5 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;NET_3_5;NET_4_0 prompt 4 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;NET_3_5;NET_4_0 prompt 4 1591;1572;1573;1574;0419; False ..\Libs\net-3.5\Mono.Reflection.dll 3.5 False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/000755 001750 001750 00000000000 11520622066 026046 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/IDb4oLinqQuery.cs000644 001750 001750 00000002345 11520622624 031154 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using System.Collections.Generic; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq { /// /// IDb4oLinqQuery is the query type of Linq to db4o. Standard query operators /// are defined in Db4oLinqQueryExtensions. /// /// The type of the objects that are queried from the database. public interface IDb4oLinqQuery : IDb4oLinqQuery, IEnumerable { } public interface IDb4oLinqQuery : IEnumerable { } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/000755 001750 001750 00000000000 11520622070 030363 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/OrderByDescendingClauseVisitor.cs000644 001750 001750 00000002512 11520622624 036707 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Linq.Expressions; using System.Reflection; using Db4objects.Db4o.Internal.Caching; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.Internals; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Expressions { internal class OrderByDescendingClauseVisitor : OrderByClauseVisitorBase { private static ICache4 _cache = ExpressionCacheFactory.NewInstance(10); protected override ICache4 GetCachingStrategy() { return _cache; } protected override void ApplyDirection(IQuery query) { query.OrderDescending(); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionCacheFactory.cs000644 001750 001750 00000002211 11520622624 035247 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Linq.Expressions; using Db4objects.Db4o.Internal.Caching; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.Internals; namespace Db4objects.Db4o.Linq.Expressions { internal class ExpressionCacheFactory { internal static ICache4 NewInstance(int cacheSize) { return CacheFactory.For(CacheFactory.New2QXCache(cacheSize), ExpressionEqualityComparer.Instance); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/WhereClauseVisitor.cs000644 001750 001750 00000014413 11520622624 034432 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Linq.Expressions; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.Internals; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Expressions { internal class WhereClauseVisitor : ExpressionQueryBuilder { private static readonly ICache4 _cache = ExpressionCacheFactory.NewInstance(42); protected override ICache4 GetCachingStrategy() { return _cache; } protected override void VisitMethodCall(MethodCallExpression m) { Visit(m.Object); VisitExpressionList(m.Arguments); if (OptimizeableMethodConstrains.IsStringMethod(m.Method)) { ProcessStringMethod(m); return; } if (OptimizeableMethodConstrains.IsIListOrICollectionOfTMethod(m.Method)) { ProcessCollectionMethod(m); return; } AnalyseMethod(Recorder, m.Method); } private void ProcessStringMethod(MethodCallExpression call) { switch (call.Method.Name) { case "EndsWith": RecordConstraintApplication(c => c.EndsWith(true)); return; case "StartsWith": RecordConstraintApplication(c => c.StartsWith(true)); return; case "Contains": RecordConstraintApplication(c => c.Contains()); return; case "Equals": return; } CannotOptimize(call); } private void RecordConstraintApplication(Func application) { Recorder.Add(ctx => ctx.ApplyConstraint(application)); } private void ProcessCollectionMethod(MethodCallExpression call) { switch (call.Method.Name) { case "Contains": if (IsCallOnCollectionOfStrings(call)) { RecordConstraintApplication(c => c.Contains()); } return; } CannotOptimize(call); } private static bool IsCallOnCollectionOfStrings(MethodCallExpression call) { return call.Method.DeclaringType.IsGenericType && call.Method.DeclaringType.GetGenericArguments()[0] == typeof(string); } private static bool IsComparisonExpression(Expression expression) { switch (expression.NodeType) { case ExpressionType.Equal: case ExpressionType.NotEqual: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.GreaterThan: case ExpressionType.GreaterThanOrEqual: return true; default: return false; } } private static bool IsConditionalExpression(Expression expression) { switch (expression.NodeType) { case ExpressionType.AndAlso: case ExpressionType.OrElse: return true; default: return false; } } protected override void VisitBinary(BinaryExpression b) { if (IsConditionalExpression(b)) { ProcessConditionalExpression(b); return; } if (IsComparisonExpression(b)) { ProcessPredicateExpression(b); return; } CannotOptimize(b); } protected override void VisitUnary(UnaryExpression u) { var operand = u.Operand; if (u.NodeType == ExpressionType.Not) { Visit(operand); RecordConstraintApplication(c => c.Not()); return; } if (u.NodeType == ExpressionType.Convert) { Visit(operand); return; } CannotOptimize(u); } private void ProcessConditionalExpression(BinaryExpression b) { VisitPreservingQuery(b.Left); VisitPreservingQuery(b.Right); switch (b.NodeType) { case ExpressionType.AndAlso: Recorder.Add(ctx => ctx.ApplyConstraint(c => c.And(ctx.PopConstraint()))); break; case ExpressionType.OrElse: Recorder.Add(ctx => ctx.ApplyConstraint(c => c.Or(ctx.PopConstraint()))); break; } } private void VisitPreservingQuery(Expression expression) { PreservingQuery(() => Visit(expression)); } private void PreservingQuery(Action action) { Recorder.Add(ctx => ctx.SaveQuery()); action(); Recorder.Add(ctx => ctx.RestoreQuery()); } private void ProcessPredicateExpression(BinaryExpression b) { if (ParameterReferenceOnLeftSide(b)) { Visit(b.Left); Visit(b.Right); } else { Visit(b.Right); Visit(b.Left); } ProcessPredicateExpressionOperator(b); } protected override void VisitMemberAccess(MemberExpression m) { if (!StartsWithParameterReference(m)) CannotOptimize(m); ProcessMemberAccess(m); } protected override void VisitConstant(ConstantExpression c) { var value = c.Value; Recorder.Add(ctx => ctx.PushConstraint(ctx.CurrentQuery.Constrain(ctx.ResolveValue(value)))); } static bool ParameterReferenceOnLeftSide(BinaryExpression b) { if (StartsWithParameterReference(b.Left)) return true; if (StartsWithParameterReference(b.Right)) return false; CannotOptimize(b); return false; } private void ProcessPredicateExpressionOperator(BinaryExpression b) { switch (b.NodeType) { case ExpressionType.Equal: break; case ExpressionType.NotEqual: RecordConstraintApplication(c => c.Not()); break; case ExpressionType.LessThan: RecordConstraintApplication(c => c.Smaller()); break; case ExpressionType.LessThanOrEqual: RecordConstraintApplication(c => c.Smaller().Equal()); break; case ExpressionType.GreaterThan: RecordConstraintApplication(c => c.Greater()); break; case ExpressionType.GreaterThanOrEqual: RecordConstraintApplication(c => c.Greater().Equal()); break; default: CannotOptimize(b); break; } } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/OrderByClauseVisitorBase.cs000644 001750 001750 00000003274 11520622624 035524 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Linq.Expressions; using Db4objects.Db4o.Linq.Internals; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Expressions { internal abstract class OrderByClauseVisitorBase : ExpressionQueryBuilder { protected abstract void ApplyDirection(IQuery query); protected override void VisitMethodCall(MethodCallExpression methodCall) { Visit(methodCall.Object); AnalyseMethod(Recorder, methodCall.Method); } protected override void VisitMemberAccess(MemberExpression m) { ProcessMemberAccess(m); } public override IQueryBuilderRecord Process(LambdaExpression expression) { if (!StartsWithParameterReference(expression.Body)) CannotOptimize(expression.Body); return ApplyDirection(base.Process(expression)); } private IQueryBuilderRecord ApplyDirection(IQueryBuilderRecord record) { QueryBuilderRecorder recorder = new QueryBuilderRecorder(record); recorder.Add(ctx => ApplyDirection(ctx.CurrentQuery)); return recorder.Record; } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionQueryBuilder.cs000644 001750 001750 00000012070 11520622624 035334 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Linq.Expressions; using System.Reflection; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.CodeAnalysis; using Db4objects.Db4o.Linq.Internals; using Expression=System.Linq.Expressions.Expression; using UnaryExpression=System.Linq.Expressions.UnaryExpression; namespace Db4objects.Db4o.Linq.Expressions { internal abstract class ExpressionQueryBuilder : ExpressionVisitor { private QueryBuilderRecorder _recorder; public QueryBuilderRecorder Recorder { get { return _recorder; } } public virtual IQueryBuilderRecord Process(LambdaExpression expression) { return ProcessExpression(SubtreeEvaluator.Evaluate(Normalize(expression))); } private static Expression Normalize(Expression expression) { return new ExpressionTreeNormalizer().Normalize(expression); } protected abstract ICache4 GetCachingStrategy(); private IQueryBuilderRecord ProcessExpression(Expression expression) { return GetCachingStrategy().Produce(expression, CreateRecord); } private IQueryBuilderRecord CreateRecord(Expression expression) { _recorder = new QueryBuilderRecorder(); Visit(expression); return _recorder.Record; } private static bool IsParameter(Expression expression) { return expression.NodeType == ExpressionType.Parameter; } protected static bool StartsWithParameterReference(Expression expression) { if (IsParameter(expression)) return true; var unary = expression as UnaryExpression; if (unary != null) return StartsWithParameterReference(unary.Operand); var me = expression as MemberExpression; if (me != null) return StartsWithParameterReference(me.Expression); var call = expression as MethodCallExpression; if (call != null && call.Object != null) return StartsWithParameterReference(call.Object); return false; } protected static bool IsFieldAccessExpression(MemberExpression m) { return m.Member.MemberType == MemberTypes.Field; } protected static bool IsPropertyAccessExpression(MemberExpression m) { return m.Member.MemberType == MemberTypes.Property; } protected static MethodInfo GetGetMethod(MemberExpression m) { return ((PropertyInfo)m.Member).GetGetMethod(); } protected void ProcessMemberAccess(MemberExpression m) { Visit(m.Expression); if (IsFieldAccessExpression(m)) { Type descendingEnumType = ResolveDescendingEnumType(m); _recorder.Add( ctx => { ctx.Descend(m.Member.Name); ctx.PushDescendigFieldEnumType(descendingEnumType); }); return; } if (IsPropertyAccessExpression(m)) { AnalyseMethod(_recorder, GetGetMethod(m)); return; } CannotOptimize(m); } private static Type ResolveDescendingEnumType(Expression expression) { if (!expression.Type.IsEnum) return null; return expression.Type; } protected void AnalyseMethod(QueryBuilderRecorder recorder, MethodInfo method) { try { var analyser = MethodAnalyser.FromMethod(method); analyser.Run(recorder); } catch (Exception e) { throw new QueryOptimizationException(e.Message, e); } } protected static void CannotOptimize(Expression e) { throw new QueryOptimizationException(e.ToString()); } protected static void CannotOptimize(ElementInit init) { throw new QueryOptimizationException(init.ToString()); } protected static void CannotOptimize(MemberBinding binding) { throw new QueryOptimizationException(binding.ToString()); } protected override void VisitBinding(MemberBinding binding) { CannotOptimize(binding); } protected override void VisitConditional(ConditionalExpression conditional) { CannotOptimize(conditional); } protected override void VisitElementInitializer(ElementInit initializer) { CannotOptimize(initializer); } protected override void VisitInvocation(InvocationExpression invocation) { CannotOptimize(invocation); } protected override void VisitListInit(ListInitExpression init) { CannotOptimize(init); } protected override void VisitNew(NewExpression nex) { CannotOptimize(nex); } protected override void VisitNewArray(NewArrayExpression newArray) { CannotOptimize(newArray); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionTransformer.cs000644 001750 001750 00000024716 11520622624 035234 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { public abstract class ExpressionTransformer { protected virtual Expression Visit(Expression exp) { if (exp == null) return exp; switch (exp.NodeType) { case ExpressionType.Negate: case ExpressionType.NegateChecked: case ExpressionType.Not: case ExpressionType.Convert: case ExpressionType.ConvertChecked: case ExpressionType.ArrayLength: case ExpressionType.Quote: case ExpressionType.TypeAs: case ExpressionType.UnaryPlus: return VisitUnary((UnaryExpression)exp); case ExpressionType.Add: case ExpressionType.AddChecked: case ExpressionType.Subtract: case ExpressionType.SubtractChecked: case ExpressionType.Multiply: case ExpressionType.MultiplyChecked: case ExpressionType.Divide: case ExpressionType.Power: case ExpressionType.Modulo: case ExpressionType.And: case ExpressionType.AndAlso: case ExpressionType.Or: case ExpressionType.OrElse: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.GreaterThan: case ExpressionType.GreaterThanOrEqual: case ExpressionType.Equal: case ExpressionType.NotEqual: case ExpressionType.Coalesce: case ExpressionType.ArrayIndex: case ExpressionType.RightShift: case ExpressionType.LeftShift: case ExpressionType.ExclusiveOr: return VisitBinary((BinaryExpression)exp); case ExpressionType.TypeIs: return VisitTypeIs((TypeBinaryExpression)exp); case ExpressionType.Conditional: return VisitConditional((ConditionalExpression)exp); case ExpressionType.Constant: return VisitConstant((ConstantExpression)exp); case ExpressionType.Parameter: return VisitParameter((ParameterExpression)exp); case ExpressionType.MemberAccess: return VisitMemberAccess((MemberExpression)exp); case ExpressionType.Call: return VisitMethodCall((MethodCallExpression)exp); case ExpressionType.Lambda: return VisitLambda((LambdaExpression)exp); case ExpressionType.New: return VisitNew((NewExpression)exp); case ExpressionType.NewArrayInit: case ExpressionType.NewArrayBounds: return VisitNewArray((NewArrayExpression)exp); case ExpressionType.Invoke: return VisitInvocation((InvocationExpression)exp); case ExpressionType.MemberInit: return VisitMemberInit((MemberInitExpression)exp); case ExpressionType.ListInit: return VisitListInit((ListInitExpression)exp); default: throw new Exception(string.Format("Unhandled expression type: '{0}'", exp.NodeType)); } } protected virtual MemberBinding VisitBinding(MemberBinding binding) { switch (binding.BindingType) { case MemberBindingType.Assignment: return VisitMemberAssignment((MemberAssignment)binding); case MemberBindingType.MemberBinding: return VisitMemberMemberBinding((MemberMemberBinding)binding); case MemberBindingType.ListBinding: return VisitMemberListBinding((MemberListBinding)binding); default: throw new Exception(string.Format("Unhandled binding type '{0}'", binding.BindingType)); } } protected virtual ElementInit VisitElementInitializer(ElementInit initializer) { ReadOnlyCollection arguments = VisitExpressionList(initializer.Arguments); if (arguments != initializer.Arguments) return Expression.ElementInit(initializer.AddMethod, arguments); return initializer; } protected virtual Expression VisitUnary(UnaryExpression u) { Expression operand = Visit(u.Operand); if (operand != u.Operand) return Expression.MakeUnary(u.NodeType, operand, u.Type, u.Method); return u; } protected virtual Expression VisitBinary(BinaryExpression b) { Expression left = Visit(b.Left); Expression right = Visit(b.Right); Expression conversion = Visit(b.Conversion); if (left != b.Left || right != b.Right || conversion != b.Conversion) { if (b.NodeType == ExpressionType.Coalesce && b.Conversion != null) { return Expression.Coalesce(left, right, conversion as LambdaExpression); } else { return Expression.MakeBinary(b.NodeType, left, right, b.IsLiftedToNull, b.Method); } } return b; } protected virtual Expression VisitTypeIs(TypeBinaryExpression b) { Expression expr = Visit(b.Expression); if (expr != b.Expression) { return Expression.TypeIs(expr, b.TypeOperand); } return b; } protected virtual Expression VisitConstant(ConstantExpression c) { return c; } protected virtual Expression VisitConditional(ConditionalExpression c) { Expression test = Visit(c.Test); Expression ifTrue = Visit(c.IfTrue); Expression ifFalse = Visit(c.IfFalse); if (test != c.Test || ifTrue != c.IfTrue || ifFalse != c.IfFalse) { return Expression.Condition(test, ifTrue, ifFalse); } return c; } protected virtual Expression VisitParameter(ParameterExpression p) { return p; } protected virtual Expression VisitMemberAccess(MemberExpression m) { Expression exp = Visit(m.Expression); if (exp != m.Expression) { return Expression.MakeMemberAccess(exp, m.Member); } return m; } protected virtual Expression VisitMethodCall(MethodCallExpression m) { Expression obj = Visit(m.Object); IEnumerable args = VisitExpressionList(m.Arguments); if (obj != m.Object || args != m.Arguments) { return Expression.Call(obj, m.Method, args); } return m; } protected virtual ReadOnlyCollection VisitExpressionList(ReadOnlyCollection original) { var list = VisitList(original, Visit); if (list == null) return original; return new ReadOnlyCollection(list); } protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment) { Expression e = Visit(assignment.Expression); if (e != assignment.Expression) return Expression.Bind(assignment.Member, e); return assignment; } protected virtual MemberMemberBinding VisitMemberMemberBinding(MemberMemberBinding binding) { IEnumerable bindings = VisitBindingList(binding.Bindings); if (bindings != binding.Bindings) return Expression.MemberBind(binding.Member, bindings); return binding; } protected virtual MemberListBinding VisitMemberListBinding(MemberListBinding binding) { IEnumerable initializers = VisitElementInitializerList(binding.Initializers); if (initializers != binding.Initializers) return Expression.ListBind(binding.Member, initializers); return binding; } protected virtual IEnumerable VisitBindingList(ReadOnlyCollection original) { return VisitList(original, VisitBinding); } protected virtual IEnumerable VisitElementInitializerList(ReadOnlyCollection original) { return VisitList(original, VisitElementInitializer); } private IList VisitList(ReadOnlyCollection original, Func visit) { List list = null; for (int i = 0, n = original.Count; i < n; i++) { TElement element = visit(original[i]); if (list != null) { list.Add(element); } else if (!EqualityComparer.Default.Equals(element, original[i])) { list = new List(n); for (int j = 0; j < i; j++) { list.Add(original[j]); } list.Add(element); } } if (list != null) return list; return original; } protected virtual Expression VisitLambda(LambdaExpression lambda) { Expression body = Visit(lambda.Body); if (body != lambda.Body) return Expression.Lambda(lambda.Type, body, lambda.Parameters); return lambda; } protected virtual NewExpression VisitNew(NewExpression nex) { IEnumerable args = VisitExpressionList(nex.Arguments); if (args != nex.Arguments) { if (nex.Members != null) return Expression.New(nex.Constructor, args, nex.Members); else return Expression.New(nex.Constructor, args); } return nex; } protected virtual Expression VisitMemberInit(MemberInitExpression init) { NewExpression n = VisitNew(init.NewExpression); IEnumerable bindings = VisitBindingList(init.Bindings); if (n != init.NewExpression || bindings != init.Bindings) return Expression.MemberInit(n, bindings); return init; } protected virtual Expression VisitListInit(ListInitExpression init) { NewExpression n = VisitNew(init.NewExpression); IEnumerable initializers = VisitElementInitializerList(init.Initializers); if (n != init.NewExpression || initializers != init.Initializers) return Expression.ListInit(n, initializers); return init; } protected virtual Expression VisitNewArray(NewArrayExpression na) { IEnumerable exprs = VisitExpressionList(na.Expressions); if (exprs != na.Expressions) { if (na.NodeType == ExpressionType.NewArrayInit) { return Expression.NewArrayInit(na.Type.GetElementType(), exprs); } else { return Expression.NewArrayBounds(na.Type.GetElementType(), exprs); } } return na; } protected virtual Expression VisitInvocation(InvocationExpression iv) { IEnumerable args = VisitExpressionList(iv.Arguments); Expression expr = Visit(iv.Expression); if (args != iv.Arguments || expr != iv.Expression) return Expression.Invoke(expr, args); return iv; } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionComparison.cs000644 001750 001750 00000012330 11520622624 035031 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { internal class ExpressionComparison : ExpressionVisitor { private bool _areEqual = true; private Queue _candidates; private Expression _candidate; public bool AreEqual { get { return _areEqual; } } public ExpressionComparison(Expression a, Expression b) { _candidates = new Queue(new ExpressionEnumeration(b)); Visit(a); if (_candidates.Count > 0) Stop(); } private Expression PeekCandidate() { if (_candidates.Count == 0) return null; return _candidates.Peek(); } private Expression PopCandidate() { return _candidates.Dequeue(); } private bool CheckAreOfSameType(Expression candidate, Expression expression) { if (!CheckEqual(expression.NodeType, candidate.NodeType)) return false; if (!CheckEqual(expression.Type, candidate.Type)) return false; return true; } private void Stop() { _areEqual = false; } private T CandidateFor(T original) where T : Expression { return (T)_candidate; } protected override void Visit(Expression expression) { if (expression == null) return; if (!AreEqual) return; _candidate = PeekCandidate(); if (!CheckNotNull(_candidate)) return; if (!CheckAreOfSameType(_candidate, expression)) return; PopCandidate(); base.Visit(expression); } protected override void VisitConstant(ConstantExpression constant) { var candidate = CandidateFor(constant); if (!CheckEqual(constant.Value, candidate.Value)) return; } protected override void VisitMemberAccess(MemberExpression member) { var candidate = CandidateFor(member); if (!CheckEqual(member.Member, candidate.Member)) return; base.VisitMemberAccess(member); } protected override void VisitMethodCall(MethodCallExpression methodCall) { var candidate = CandidateFor(methodCall); if (!CheckEqual(methodCall.Method, candidate.Method)) return; base.VisitMethodCall(methodCall); } protected override void VisitParameter(ParameterExpression parameter) { var candidate = CandidateFor(parameter); if (!CheckEqual(parameter.Name, candidate.Name)) return; } protected override void VisitTypeIs(TypeBinaryExpression type) { var candidate = CandidateFor(type); if (!CheckEqual(type.TypeOperand, candidate.TypeOperand)) return; base.VisitTypeIs(type); } protected override void VisitBinary(BinaryExpression binary) { var candidate = CandidateFor(binary); if (!CheckEqual(binary.Method, candidate.Method)) return; if (!CheckEqual(binary.IsLifted, candidate.IsLifted)) return; if (!CheckEqual(binary.IsLiftedToNull, candidate.IsLiftedToNull)) return; base.VisitBinary(binary); } protected override void VisitUnary(UnaryExpression unary) { var candidate = CandidateFor(unary); if (!CheckEqual(unary.Method, candidate.Method)) return; if (!CheckEqual(unary.IsLifted, candidate.IsLifted)) return; if (!CheckEqual(unary.IsLiftedToNull, candidate.IsLiftedToNull)) return; base.VisitUnary(unary); } protected override void VisitNew(NewExpression nex) { var candidate = CandidateFor(nex); if (!CheckEqual(nex.Constructor, candidate.Constructor)) return; CompareList(nex.Members, candidate.Members); base.VisitNew(nex); } private void CompareList(ReadOnlyCollection collection, ReadOnlyCollection candidates) { CompareList(collection, candidates, (item, candidate) => EqualityComparer.Default.Equals(item, candidate)); } private void CompareList(ReadOnlyCollection collection, ReadOnlyCollection candidates, Func comparer) { if (!CheckAreOfSameSize(collection, candidates)) return; for (int i = 0; i < collection.Count; i++) { if (!comparer(collection[i], candidates[i])) { Stop(); return; } } } private bool CheckAreOfSameSize(ReadOnlyCollection collection, ReadOnlyCollection candidate) { return CheckEqual(collection.Count, candidate.Count); } private bool CheckNotNull(T t) where T : class { if (t == null) { Stop(); return false; } return true; } private bool CheckEqual(T t, T candidate) { if (!EqualityComparer.Default.Equals(t, candidate)) { Stop(); return false; } return true; } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionTreeNormalizer.cs000644 001750 001750 00000010733 11520622624 035666 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Linq.Expressions; using Db4objects.Db4o.Linq.Internals; namespace Db4objects.Db4o.Linq.Expressions { class ExpressionTreeNormalizer : ExpressionTransformer { protected override Expression VisitLambda(LambdaExpression lambda) { if (IsBooleanMemberAccess(lambda.Body)) { return Expression.Lambda(ExpandExpression(lambda.Body, true)); } return base.VisitLambda(lambda); } protected override Expression VisitUnary(UnaryExpression u) { if (u.NodeType != ExpressionType.Not) { return base.VisitUnary(u); } if (IsBooleanMemberAccess(u.Operand) || IsNonOptimizeableBooleanMethodCall(u.Operand)) { return ExpandExpression(u.Operand, false); } return base.VisitUnary(u); } protected override Expression VisitBinary(BinaryExpression b) { var expression = NormalizeBooleanMemberAccess(b); return NormalizeVisualBasicOperator(expression) ?? base.VisitBinary(expression); } protected override Expression VisitMethodCall(MethodCallExpression method) { Visit(method.Object); VisitExpressionList(method.Arguments); if (IsNonOptimizeableBooleanMethodCall(method)) { return ExpandExpression(method, true); } return base.VisitMethodCall(method); } private static bool IsNonOptimizeableBooleanMethodCall(Expression expression) { return expression.NodeType == ExpressionType.Call && expression.Type == typeof(bool) && !IsOptimizeableMethodCall((MethodCallExpression) expression); } private static bool IsOptimizeableMethodCall(MethodCallExpression expression) { return OptimizeableMethodConstrains.CanBeOptimized(expression.Method); } private static BinaryExpression ExpandExpression(Expression expression, bool value) { return Expression.Equal(expression, Expression.Constant(value)); } private static bool IsBooleanMemberAccess(Expression expression) { return expression.NodeType == ExpressionType.MemberAccess && expression.Type == typeof(bool); } private static BinaryExpression NormalizeBooleanMemberAccess(BinaryExpression expression) { if (!IsLogicalOperator(expression)) return expression; if (IsBooleanMemberAccess(expression.Right)) { expression = Expression.MakeBinary(expression.NodeType, expression.Left, ExpandExpression(expression.Right, true)); } if (IsBooleanMemberAccess(expression.Left)) { expression = Expression.MakeBinary(expression.NodeType, ExpandExpression(expression.Left, true), expression.Right); } return expression; } private static bool IsLogicalOperator(Expression expression) { switch (expression.NodeType) { case ExpressionType.OrElse: case ExpressionType.AndAlso: return true; default: return false; } } private static Expression NormalizeVisualBasicOperator(BinaryExpression b) { var call = b.Left as MethodCallExpression; if (call == null) return null; if (call.Object != null) return null; if (call.Method.DeclaringType.FullName != "Microsoft.VisualBasic.CompilerServices.Operators") return null; switch (call.Method.Name) { case "CompareString": { switch (b.NodeType) { case ExpressionType.Equal: return ToStringEquals(call); case ExpressionType.NotEqual: return Expression.Not(ToStringEquals(call)); } return null; } } return null; } private static MethodCallExpression ToStringEquals(MethodCallExpression call) { var stringEquals = typeof(string).GetMethod("Equals", new[] {typeof(string)}); return Expression.Call(call.Arguments[0], stringEquals, call.Arguments[1]); } public Expression Normalize(Expression expression) { return Visit(expression); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/SubtreeEvaluator.cs000644 001750 001750 00000006425 11520622624 034143 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { class Set { #if SILVERLIGHT Dictionary items = new Dictionary(); #else HashSet items = new HashSet(); #endif public bool Contains(T item) { #if SILVERLIGHT return items.ContainsKey(item); #else return items.Contains(item); #endif } public void Add(T item) { #if SILVERLIGHT items.Add (item, item); #else items.Add(item); #endif } } public class SubtreeEvaluator : ExpressionTransformer { private Set _candidates; private SubtreeEvaluator(Set candidates) { _candidates = candidates; } public static Expression Evaluate(Expression expression) { var nominator = new Nominator(expression, exp => exp.NodeType != ExpressionType.Parameter); return new SubtreeEvaluator(nominator.Candidates).Visit(expression); } protected override Expression Visit(Expression expression) { if (expression == null) return null; if (_candidates.Contains(expression)) return EvaluateCandidate(expression); return base.Visit(expression); } private Expression EvaluateCandidate(Expression expression) { if (expression.NodeType == ExpressionType.Constant) return expression; var evaluator = Expression.Lambda(expression).Compile(); return Expression.Constant( #if !CF_3_5 evaluator.DynamicInvoke(null), #else evaluator.Method.Invoke(evaluator.Target, new object[0]), #endif expression.Type); } class Nominator : ExpressionTransformer { readonly Func _predicate; readonly Set _candidates = new Set(); bool cannotBeEvaluated; public Set Candidates { get { return _candidates; } } public Nominator(Expression expression, Func predicate) { _predicate = predicate; Visit(expression); } private void AddCandidate(Expression expression) { _candidates.Add(expression); } // TODO: refactor protected override Expression Visit(Expression expression) { if (expression == null) return null; bool saveCannotBeEvaluated = cannotBeEvaluated; cannotBeEvaluated = false; base.Visit(expression); if (cannotBeEvaluated) return expression; if (_predicate(expression)) { AddCandidate(expression); } else { cannotBeEvaluated = true; } cannotBeEvaluated |= saveCannotBeEvaluated; return expression; } } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionVisitor.cs000644 001750 001750 00000016074 11520622624 034367 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.ObjectModel; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { internal abstract class ExpressionVisitor { protected virtual void Visit(Expression expression) { if (expression == null) return; switch (expression.NodeType) { case ExpressionType.Negate: case ExpressionType.NegateChecked: case ExpressionType.Not: case ExpressionType.Convert: case ExpressionType.ConvertChecked: case ExpressionType.ArrayLength: case ExpressionType.Quote: case ExpressionType.TypeAs: case ExpressionType.UnaryPlus: VisitUnary((UnaryExpression)expression); break; case ExpressionType.Add: case ExpressionType.AddChecked: case ExpressionType.Subtract: case ExpressionType.SubtractChecked: case ExpressionType.Multiply: case ExpressionType.MultiplyChecked: case ExpressionType.Divide: case ExpressionType.Power: case ExpressionType.Modulo: case ExpressionType.And: case ExpressionType.AndAlso: case ExpressionType.Or: case ExpressionType.OrElse: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.GreaterThan: case ExpressionType.GreaterThanOrEqual: case ExpressionType.Equal: case ExpressionType.NotEqual: case ExpressionType.Coalesce: case ExpressionType.ArrayIndex: case ExpressionType.RightShift: case ExpressionType.LeftShift: case ExpressionType.ExclusiveOr: VisitBinary((BinaryExpression)expression); break; case ExpressionType.TypeIs: VisitTypeIs((TypeBinaryExpression)expression); break; case ExpressionType.Conditional: VisitConditional((ConditionalExpression)expression); break; case ExpressionType.Constant: VisitConstant((ConstantExpression)expression); break; case ExpressionType.Parameter: VisitParameter((ParameterExpression)expression); break; case ExpressionType.MemberAccess: VisitMemberAccess((MemberExpression)expression); break; case ExpressionType.Call: VisitMethodCall((MethodCallExpression)expression); break; case ExpressionType.Lambda: VisitLambda((LambdaExpression)expression); break; case ExpressionType.New: VisitNew((NewExpression)expression); break; case ExpressionType.NewArrayInit: case ExpressionType.NewArrayBounds: VisitNewArray((NewArrayExpression)expression); break; case ExpressionType.Invoke: VisitInvocation((InvocationExpression)expression); break; case ExpressionType.MemberInit: VisitMemberInit((MemberInitExpression)expression); break; case ExpressionType.ListInit: VisitListInit((ListInitExpression)expression); break; default: throw new ArgumentException(string.Format("Unhandled expression type: '{0}'", expression.NodeType)); } } protected virtual void VisitBinding(MemberBinding binding) { switch (binding.BindingType) { case MemberBindingType.Assignment: VisitMemberAssignment((MemberAssignment)binding); break; case MemberBindingType.MemberBinding: VisitMemberMemberBinding((MemberMemberBinding)binding); break; case MemberBindingType.ListBinding: VisitMemberListBinding((MemberListBinding)binding); break; default: throw new ArgumentException(string.Format("Unhandled binding type '{0}'", binding.BindingType)); } } protected virtual void VisitElementInitializer(ElementInit initializer) { VisitExpressionList(initializer.Arguments); } protected virtual void VisitUnary(UnaryExpression unary) { Visit(unary.Operand); } protected virtual void VisitBinary(BinaryExpression binary) { Visit(binary.Left); Visit(binary.Right); Visit(binary.Conversion); } protected virtual void VisitTypeIs(TypeBinaryExpression type) { Visit(type.Expression); } protected virtual void VisitConstant(ConstantExpression constant) { } protected virtual void VisitConditional(ConditionalExpression conditional) { Visit(conditional.Test); Visit(conditional.IfTrue); Visit(conditional.IfFalse); } protected virtual void VisitParameter(ParameterExpression parameter) { } protected virtual void VisitMemberAccess(MemberExpression member) { Visit(member.Expression); } protected virtual void VisitMethodCall(MethodCallExpression methodCall) { Visit(methodCall.Object); VisitExpressionList(methodCall.Arguments); } protected virtual void VisitList(ReadOnlyCollection list, Action visitor) { foreach (T element in list) { visitor(element); } } protected virtual void VisitExpressionList(ReadOnlyCollection list) where TExp : Expression { VisitList(list, Visit); } protected virtual void VisitMemberAssignment(MemberAssignment assignment) { Visit(assignment.Expression); } protected virtual void VisitMemberMemberBinding(MemberMemberBinding binding) { VisitBindingList(binding.Bindings); } protected virtual void VisitMemberListBinding(MemberListBinding binding) { VisitElementInitializerList(binding.Initializers); } protected virtual void VisitBindingList(ReadOnlyCollection list) where TBinding : MemberBinding { VisitList(list, VisitBinding); } protected virtual void VisitElementInitializerList(ReadOnlyCollection list) { VisitList(list, VisitElementInitializer); } protected virtual void VisitLambda(LambdaExpression lambda) { Visit(lambda.Body); } protected virtual void VisitNew(NewExpression nex) { VisitExpressionList(nex.Arguments); } protected virtual void VisitMemberInit(MemberInitExpression init) { VisitNew(init.NewExpression); VisitBindingList(init.Bindings); } protected virtual void VisitListInit(ListInitExpression init) { VisitNew(init.NewExpression); VisitElementInitializerList(init.Initializers); } protected virtual void VisitNewArray(NewArrayExpression newArray) { VisitExpressionList(newArray.Expressions); } protected virtual void VisitInvocation(InvocationExpression invocation) { VisitExpressionList(invocation.Arguments); Visit(invocation.Expression); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/HashCodeCalculation.cs000644 001750 001750 00000005621 11520622624 034501 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.ObjectModel; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { internal class HashCodeCalculation : ExpressionVisitor { private int _hashCode; public int HashCode { get { return _hashCode; } } public HashCodeCalculation(Expression expression) { Visit(expression); } private void Add(int i) { _hashCode *= 37; _hashCode ^= i; } protected override void Visit(Expression expression) { if (expression == null) return; Add((int)expression.NodeType); Add(expression.Type.GetHashCode()); base.Visit(expression); } protected override void VisitList(ReadOnlyCollection list, Action visitor) { Add(list.Count); base.VisitList(list, visitor); } protected override void VisitConstant(ConstantExpression constant) { if (constant != null && constant.Value != null) Add(constant.Value.GetHashCode()); } protected override void VisitMemberAccess(MemberExpression member) { Add(member.Member.GetHashCode()); base.VisitMemberAccess(member); } protected override void VisitMethodCall(MethodCallExpression methodCall) { Add(methodCall.Method.GetHashCode()); base.VisitMethodCall(methodCall); } protected override void VisitParameter(ParameterExpression parameter) { Add(parameter.Name.GetHashCode()); } protected override void VisitTypeIs(TypeBinaryExpression type) { Add(type.TypeOperand.GetHashCode()); base.VisitTypeIs(type); } protected override void VisitBinary(BinaryExpression binary) { if (binary.Method != null) Add(binary.Method.GetHashCode()); if (binary.IsLifted) Add(1); if (binary.IsLiftedToNull) Add(1); base.VisitBinary(binary); } protected override void VisitUnary(UnaryExpression unary) { if (unary.Method != null) Add(unary.Method.GetHashCode()); if (unary.IsLifted) Add(1); if (unary.IsLiftedToNull) Add(1); base.VisitUnary(unary); } protected override void VisitNew(NewExpression nex) { Add(nex.Constructor.GetHashCode()); VisitList(nex.Members, member => Add(member.GetHashCode())); base.VisitNew(nex); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionEnumeration.cs000644 001750 001750 00000002643 11520622624 035213 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { internal class ExpressionEnumeration : ExpressionVisitor, IEnumerable { private List _expressions = new List(); public ExpressionEnumeration(Expression expression) { Visit(expression); } protected override void Visit(Expression expression) { if (expression == null) return; _expressions.Add(expression); base.Visit(expression); } public IEnumerator GetEnumerator() { return _expressions.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/QueryableTransformer.cs000644 001750 001750 00000015027 11520622624 035021 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF_3_5 using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Linq.Expressions; using System.Reflection; using Db4objects.Db4o.Linq.Internals; namespace Db4objects.Db4o.Linq.Expressions { internal class QueryableTransformer : ExpressionTransformer { private bool _optimize = true; private bool Optimize { get { return _optimize; } set { _optimize = value; } } public static Expression Transform(Expression expression) { return new QueryableTransformer().Visit(expression); } protected override Expression VisitLambda(LambdaExpression lambda) { return lambda; } protected override Expression VisitMethodCall(MethodCallExpression call) { if (IsQueryableExtensionMethod(call.Method)) { return ReplaceQueryableMethodCall(call); } return base.VisitMethodCall(call); } protected override Expression VisitConstant (ConstantExpression constant) { var queryable = constant.Value as IDb4oLinqQueryable; if (queryable == null) return constant; return Expression.Constant(queryable.GetQuery()); } private static bool IsQueryableExtensionMethod(MethodInfo method) { return method.IsExtension() && typeof(IQueryable).IsAssignableFrom(method.GetParameters().First().ParameterType); } private MethodCallExpression ReplaceQueryableMethodCall(MethodCallExpression call) { var target = null as Expression; if (call.Object != null) target = Visit(call.Object); var arguments = VisitExpressionList(call.Arguments); var method = ReplaceQueryableMethod(call.Method); return Expression.Call(target, method, ProcessArguments(method, arguments)); } private IEnumerable ProcessArguments(MethodInfo method, ReadOnlyCollection arguments) { var parameters = method.GetParameters(); for (int i = 0; i < parameters.Length; i++) yield return TryUnquoteExpression(arguments[i], parameters[i].ParameterType); } private static Expression TryUnquoteExpression(Expression expression, Type delegateType) { if (expression.NodeType != ExpressionType.Quote) return expression; var lambda = (LambdaExpression)((UnaryExpression)expression).Operand; if (lambda.Type == delegateType) return lambda; return expression; } private MethodInfo ReplaceQueryableMethod(MethodInfo method) { MethodInfo match; if (Optimize) { if (TryMatchMethod(typeof(Db4oLinqQueryExtensions), method, out match)) return match; } if (TryMatchMethod(typeof(Enumerable), method, out match)) { if (Optimize) Optimize = false; return match; } throw new ArgumentException(string.Format("Failed to find a replacement for {0}", method)); } private static bool TryMatchMethod(Type target, MethodInfo method, out MethodInfo match) { foreach (var candidate in target.GetMethods()) { if (TryMatchMethod(method, candidate, out match)) return true; } match = null; return false; } private static bool TryMatchMethod(MethodInfo method, MethodInfo candidate, out MethodInfo match) { match = null; if (candidate.Name != method.Name) return false; if (!candidate.IsExtension()) return false; if (!LengthMatch(method.GetParameters(), candidate.GetParameters())) return false; if (!TryMatchGenericMethod(method, ref candidate)) return false; if (!TryMatchMethodSignature(method, candidate)) return false; match = candidate; return true; } private static bool TryMatchGenericMethod(MethodInfo method, ref MethodInfo candidate) { if (method.IsGenericMethod) { if (!candidate.IsGenericMethod) return false; if (!LengthMatch(candidate.GetGenericArguments(), method.GetGenericArguments())) return false; candidate = candidate.MakeGenericMethodFrom(method); } return true; } private static bool TryMatchMethodSignature(MethodInfo method, MethodInfo candidate) { var parameters = method.GetParameterTypes(); var candidateParameters = candidate.GetParameterTypes(); var compare = GetTypeComparer(candidate.DeclaringType); if (!compare(method.ReturnType, candidate.ReturnType)) return false; for (int i = 0; i < candidateParameters.Length; i++) { if (!compare(parameters[i], candidateParameters[i])) return false; } return true; } private static bool LengthMatch(T1[] a, T2[] b) { return a.Length == b.Length; } private static Func GetTypeComparer(Type type) { Func mapper; if (!_mappers.TryGetValue(type, out mapper)) mapper = t => t; return (a, b) => { if (a == b) return true; return mapper(a) == b; }; } private static Dictionary> _mappers = new Dictionary> { { typeof(Db4oLinqQueryExtensions), MapQueryableToDb4o }, { typeof(Enumerable), MapQueryableToEnumerable }, }; private static Type MapQueryableToDb4o(Type type) { if (type.IsGenericInstanceOf(typeof(IQueryable<>)) || type.IsGenericInstanceOf(typeof(IOrderedQueryable<>))) { type = typeof(IDb4oLinqQuery<>).MakeGenericTypeFrom(type); } return type; } private static Type MapQueryableToEnumerable(Type type) { if (type.IsGenericInstanceOf(typeof(IQueryable<>))) { type = typeof(IEnumerable<>).MakeGenericTypeFrom(type); } else if (type.IsGenericInstanceOf(typeof(IOrderedQueryable<>))) { type = typeof(IOrderedEnumerable<>).MakeGenericTypeFrom(type); } else if (type.IsGenericInstanceOf(typeof(Expression<>))) { type = type.GetFirstGenericArgument(); } else if (type == typeof(IQueryable)) { type = typeof(IEnumerable); } return type; } } } #endifsrc/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/OrderByAscendingClauseVisitor.cs000644 001750 001750 00000002366 11520622624 036546 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Linq.Expressions; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.Internals; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Expressions { internal class OrderByAscendingClauseVisitor : OrderByClauseVisitorBase { private static ICache4 _cache = ExpressionCacheFactory.NewInstance(10); protected override ICache4 GetCachingStrategy() { return _cache; } protected override void ApplyDirection(IQuery query) { query.OrderAscending(); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Expressions/ExpressionEqualityComparer.cs000644 001750 001750 00000002300 11520622624 036201 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Linq.Expressions; namespace Db4objects.Db4o.Linq.Expressions { public class ExpressionEqualityComparer : IEqualityComparer { public static ExpressionEqualityComparer Instance = new ExpressionEqualityComparer(); public bool Equals(Expression a, Expression b) { return new ExpressionComparison(a, b).AreEqual; } public int GetHashCode(Expression expression) { return new HashCodeCalculation(expression).HashCode; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/000755 001750 001750 00000000000 11520622070 030000 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/QueryBuilderContext.cs000644 001750 001750 00000004565 11520622624 034250 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Internals { internal class QueryBuilderContext { private readonly IQuery _root; private IQuery _currentQuery; private readonly Stack _constraints = new Stack(); private Stack _descendStack = new Stack(); private Type _descendigFieldEnum; public IQuery CurrentQuery { get { return _currentQuery; } } public QueryBuilderContext(IQuery root) { _root = root; _currentQuery = _root; } internal void PushDescendigFieldEnumType(Type descendigFieldEnum) { _descendigFieldEnum = descendigFieldEnum; } private Type PopDescendigFieldEnumType() { Type returnType = _descendigFieldEnum; _descendigFieldEnum = null; return returnType; } public void PushConstraint(IConstraint constraint) { _constraints.Push(constraint); } public IConstraint PopConstraint() { return _constraints.Pop(); } public void ApplyConstraint(Func constraint) { PushConstraint(constraint(PopConstraint())); } internal object ResolveValue(object value) { Type type = PopDescendigFieldEnumType(); return (type != null) ? Enum.ToObject(type, value) : value; } public void Descend(string name) { _currentQuery = _currentQuery.Descend(name); } public void SaveQuery() { _descendStack.Push(_currentQuery); } public void RestoreQuery() { _currentQuery = _descendStack.Pop(); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/Db4oLinqQueryable.cs000644 001750 001750 00000005224 11520622624 033625 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF_3_5 using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Db4objects.Db4o.Linq.Expressions; namespace Db4objects.Db4o.Linq.Internals { internal class Db4oQueryable : IDb4oLinqQueryable, IQueryProvider { Expression _expression; IDb4oLinqQuery _query; public Type ElementType { get { return typeof(T); } } public Expression Expression { get { return _expression; } } public IQueryProvider Provider { get { return this; } } public Db4oQueryable(Expression expression) { _expression = expression; } public Db4oQueryable(IDb4oLinqQuery query) { _expression = Expression.Constant(this); _query = query; } public IDb4oLinqQuery GetQuery() { return _query; } public IEnumerator GetEnumerator () { return Execute>(_expression).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator () { return GetEnumerator(); } public IQueryable CreateQuery(Expression expression) { return new Db4oQueryable(expression); } public IQueryable CreateQuery(Expression expression) { return (IQueryable)Activator.CreateInstance( MakeGenericDb4oQueryable(expression.Type), expression); } private static Type MakeGenericDb4oQueryable(Type type) { return typeof(Db4oQueryable<>).MakeGenericType(type.GetFirstGenericArgument()); } private static Expression TransformQuery(Expression expression) { var result = QueryableTransformer.Transform(expression); return result; } public TResult Execute(Expression expression) { return Expression.Lambda>(TransformQuery(expression)).Compile().Invoke(); } public object Execute(Expression expression) { return Expression.Lambda(TransformQuery(expression)).Compile().DynamicInvoke(); } } } #endifsrc/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/OptimizeableMethodConstrains.cs000644 001750 001750 00000002703 11520622624 036110 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace Db4objects.Db4o.Linq.Internals { internal class OptimizeableMethodConstrains { public static bool CanBeOptimized(MethodInfo method) { return IsIListOrICollectionOfTMethod(method) || IsStringMethod(method); } public static bool IsStringMethod(MethodInfo method) { return method.DeclaringType == typeof(string); } public static bool IsIListOrICollectionOfTMethod(MethodInfo method) { Type declaringType = method.DeclaringType; return declaringType.IsGenericInstanceOf(typeof(ICollection<>)) || typeof(IList).IsAssignableFrom(declaringType) || declaringType == typeof(Enumerable); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/UnoptimizedQuery.cs000644 001750 001750 00000003433 11520622624 033674 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace Db4objects.Db4o.Linq.Internals { internal class UnoptimizedQuery : IDb4oLinqQueryInternal { private IEnumerable _result; public UnoptimizedQuery(IEnumerable result) { if (result == null) throw new ArgumentNullException("result"); _result = result; } public IEnumerable Result { get { return _result; } } public IEnumerator GetEnumerator() { return _result.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } #region IDb4oLinqQueryInternal Members public IEnumerable UnoptimizedThenBy(Func function) { return ((IOrderedEnumerable)_result).ThenBy(function); } public IEnumerable UnoptimizedThenByDescending(Func function) { return ((IOrderedEnumerable)_result).ThenByDescending(function); } public IEnumerable UnoptimizedWhere(Func func) { return _result.Where(func); } #endregion } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/ObjectSequence.cs000644 001750 001750 00000004225 11520622624 033236 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using Db4objects.Db4o; namespace Db4objects.Db4o.Linq.Internals { /// /// A generic wrapper around a not generic IEnumerable, /// Faithfully hoping that all items in the enumeration /// are of the same kind, otherwise it will throw a /// ClassCastException on access. /// /// The type of the items public class ObjectSequence : IEnumerable { private IEnumerable _enumerable; public ObjectSequence(IEnumerable enumerable) { _enumerable = enumerable; } public IEnumerator GetEnumerator() { return new ObjectSequenceEnumerator(this); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } internal class ObjectSequenceEnumerator : IEnumerator { private IEnumerator _enumerator; public T Current { get { return (T)_enumerator.Current; } } object IEnumerator.Current { get { return Current; } } public ObjectSequenceEnumerator(ObjectSequence sequence) { _enumerator = sequence._enumerable.GetEnumerator(); } public bool MoveNext() { return _enumerator.MoveNext(); } public void Reset() { _enumerator.Reset(); } public void Dispose() { IDisposable enumerator = _enumerator as IDisposable; if (enumerator == null) return; enumerator.Dispose(); } } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/ObjectSetWrapper.cs000644 001750 001750 00000002022 11520622624 033553 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using Db4objects.Db4o; namespace Db4objects.Db4o.Linq.Internals { public class ObjectSetWrapper : ObjectSequence { private IObjectSet _set; public int Count { get { return _set.Count; } } public ObjectSetWrapper(IObjectSet set) : base(set) { _set = set; } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/Db4oQuery.cs000644 001750 001750 00000007161 11520622624 032157 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal.Query.Processor; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Internals { internal class Db4oQuery : IDb4oLinqQueryInternal { private readonly ISodaQueryFactory _queryFactory; private readonly IQueryBuilderRecord _record; public Db4oQuery(ISodaQueryFactory queryFactory) { if (queryFactory == null) throw new ArgumentNullException("queryFactory"); _queryFactory = queryFactory; _record = NullQueryBuilderRecord.Instance; } public Db4oQuery(Db4oQuery parent, IQueryBuilderRecord record) { _queryFactory = parent.QueryFactory; _record = new CompositeQueryBuilderRecord(parent.Record, record); } public ISodaQueryFactory QueryFactory { get { return _queryFactory; } } public IQueryBuilderRecord Record { get { return _record; } } public int Count { get { return Execute().Count; } } public ObjectSetWrapper GetExtentResult() { var query = NewQuery(); return Wrap(ExecuteQuery(query, MonitorUnoptimizedQuery)); } private IObjectSet Execute() { var query = NewQuery(); _record.Playback(query); return ExecuteQuery(query, MonitorOptimizedQuery); } private static IObjectSet ExecuteQuery(IQuery query, Action4 monitorAction) { var result = query.Execute(); ((IInternalQuery)query).Container.WithEnvironment(monitorAction); return result; } private void MonitorOptimizedQuery() { My.Instance.OnOptimizedQuery(); } private void MonitorUnoptimizedQuery() { My.Instance.OnUnoptimizedQuery(); } private IQuery NewQuery() { var query = _queryFactory.Query(); query.Constrain(typeof(T)); return query; } static ObjectSetWrapper Wrap(IObjectSet set) { return new ObjectSetWrapper(set); } public IEnumerator GetEnumerator() { return Wrap(Execute()).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } #region IDb4oLinqQueryInternal Members public IEnumerable UnoptimizedThenBy(Func function) { throw new NotImplementedException("cannot fallback on UnoptimizedThenBy"); } public IEnumerable UnoptimizedThenByDescending(Func function) { throw new NotImplementedException("cannot fallback on UnoptimizedThenBy"); /* IOrderByRecord record = _orderByRecord; IOrderedEnumerable ordered = record.OrderBy(this); record = record.Next; while (record != null) { ordered = record.ThenBy(record); } return ordered.ThenByDescending(function); * */ } public IEnumerable UnoptimizedWhere(Func func) { return GetExtentResult().Where(func); } #endregion } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/LinqQueryMonitorImpl.cs000644 001750 001750 00000001621 11520622624 034400 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Linq; namespace Db4objects.Db4o.Internal.Linq { public class LinqQueryMonitorImpl : ILinqQueryMonitor { public void OnOptimizedQuery() { } public void OnUnoptimizedQuery() { } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/PlaceholderQuery.cs000644 001750 001750 00000002564 11520622624 033613 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Collections; using System.Collections.Generic; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Internals { internal class PlaceHolderQuery : IDb4oLinqQuery { private ISodaQueryFactory _queryFactory; public ISodaQueryFactory QueryFactory { get { return _queryFactory; } } public PlaceHolderQuery(ISodaQueryFactory queryFactory) { _queryFactory = queryFactory; } public IEnumerator GetEnumerator() { var query = _queryFactory.Query(); query.Constrain(typeof(T)); return new ObjectSequence(query.Execute()).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/Extensions.cs000644 001750 001750 00000003425 11520622624 032477 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; namespace Db4objects.Db4o.Linq.Internals { internal static class Extensions { public static Type[] GetParameterTypes(this MethodBase self) { return self.GetParameters().Select(p => p.ParameterType).ToArray(); } public static Type MakeGenericTypeFrom(this Type self, Type type) { return self.MakeGenericType(type.GetGenericArguments()); } public static Type GetFirstGenericArgument(this Type self) { return self.GetGenericArguments()[0]; } public static bool IsGenericInstanceOf(this Type self, Type type) { return self.IsGenericType && self.GetGenericTypeDefinition() == type; } public static MethodInfo MakeGenericMethodFrom(this MethodInfo self, MethodInfo method) { return self.MakeGenericMethod(method.GetGenericArguments()); } public static bool IsExtension(this MethodInfo self) { return self.GetCustomAttributes(typeof(ExtensionAttribute), false).Length > 0; } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/QueryBuilderRecorder.cs000644 001750 001750 00000005516 11520622624 034366 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq.Internals { internal interface IQueryBuilderRecord { void Playback(IQuery query); void Playback(QueryBuilderContext context); } internal class NullQueryBuilderRecord : IQueryBuilderRecord { public static readonly NullQueryBuilderRecord Instance = new NullQueryBuilderRecord(); private NullQueryBuilderRecord() { } public void Playback(IQuery query) { } public void Playback(QueryBuilderContext context) { } } internal abstract class QueryBuilderRecordImpl : IQueryBuilderRecord { public void Playback(IQuery query) { Playback(new QueryBuilderContext(query)); } public abstract void Playback(QueryBuilderContext context); } internal class CompositeQueryBuilderRecord : QueryBuilderRecordImpl { private readonly IQueryBuilderRecord _first; private readonly IQueryBuilderRecord _second; public CompositeQueryBuilderRecord(IQueryBuilderRecord first, IQueryBuilderRecord second) { _first = first; _second = second; } override public void Playback(QueryBuilderContext context) { context.SaveQuery(); _first.Playback(context); context.RestoreQuery(); _second.Playback(context); } } internal class ChainedQueryBuilderRecord : QueryBuilderRecordImpl { private readonly Action _action; private readonly IQueryBuilderRecord _next; public ChainedQueryBuilderRecord(IQueryBuilderRecord next, Action action) { _next = next; _action = action; } override public void Playback(QueryBuilderContext context) { _next.Playback(context); _action(context); } } internal class QueryBuilderRecorder { private IQueryBuilderRecord _last = NullQueryBuilderRecord.Instance; public QueryBuilderRecorder() { } public QueryBuilderRecorder(IQueryBuilderRecord record) { _last = record; } public IQueryBuilderRecord Record { get { return _last; } } public void Add(Action action) { _last = new ChainedQueryBuilderRecord(_last, action); } } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Internals/IDb4oLinqQueryInternal.cs000644 001750 001750 00000002033 11520622624 034523 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Linq.Internals { using System; using System.Collections.Generic; interface IDb4oLinqQueryInternal : IDb4oLinqQuery { IEnumerable UnoptimizedThenBy(Func function); IEnumerable UnoptimizedThenByDescending(Func function); IEnumerable UnoptimizedWhere(Func func); } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/QueryOptimizationException.cs000644 001750 001750 00000002022 11520622624 033764 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4objects.Db4o.Linq { public class QueryOptimizationException : Exception { internal QueryOptimizationException() { } internal QueryOptimizationException(string message) : base(message) { } internal QueryOptimizationException(string message, Exception innerException) : base(message, innerException) { } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/ObjectContainerExtensions.cs000644 001750 001750 00000003522 11520622624 033530 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using Db4objects.Db4o.Linq.Internals; using Db4objects.Db4o.Query; namespace Db4objects.Db4o.Linq { public static class ObjectContainerExtensions { /// /// This is the entry point of Linq to db4o. /// It allows the compiler to call the standard query operators /// in IDb4oLinqQuery. The optimized methods are defined as extension methods /// on the IDb4oLinqQuery marker interface. /// /// The type to query the ObjectContainer /// A query factory (any IObjectContainer implementation) /// A IDb4oLinqQuery marker interface public static IDb4oLinqQuery Cast(this ISodaQueryFactory queryFactory) { if (typeof(T) == typeof(object)) return new PlaceHolderQuery(queryFactory); return new Db4oQuery(queryFactory); } #if !CF_3_5 public static IDb4oLinqQueryable AsQueryable(this ISodaQueryFactory queryFactory) { return queryFactory.Cast().AsQueryable(); } #endif } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/000755 001750 001750 00000000000 11520622070 030417 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/ReflectionMethodAnalyser.cs000644 001750 001750 00000011060 11520622624 035624 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF && !SILVERLIGHT using System; using System.Reflection; using System.Reflection.Emit; using Mono.Reflection; using Db4objects.Db4o.Activation; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.Internals; using Db4objects.Db4o.Internal.Caching; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal class ReflectionMethodAnalyser : IMethodAnalyser { private static ICache4 _fieldCache = CacheFactory.For(CacheFactory.New2QXCache(5)); private static ILPattern ActivateCall() { return new ActivateCallPattern(); } private class ActivateCallPattern : ILPattern { static ILPattern pattern = ILPattern.Sequence( ILPattern.Optional(OpCodes.Nop), ILPattern.OpCode(OpCodes.Ldarg_0), ILPattern.OpCode(OpCodes.Ldc_I4_0), ILPattern.Either( ILPattern.OpCode(OpCodes.Call), ILPattern.OpCode(OpCodes.Callvirt))); public override void Match(MatchContext context) { pattern.Match(context); if (!context.IsMatch) return; var match = GetLastMatchingInstruction(context); var method = (MethodInfo)match.Operand; if (!IsActivateCall(method)) context.IsMatch = false; } private static bool IsActivateCall(MethodInfo method) { if (method == null) return false; if (method.IsStatic) return false; if (method.Name != "Activate") return false; var parameters = method.GetParameters(); if (parameters.Length != 1) return false; if (parameters[0].ParameterType != typeof(ActivationPurpose)) return false; return true; } } private static ILPattern BackingField() { return new BackingFieldPattern(); } private class BackingFieldPattern : ILPattern { public static readonly object BackingFieldKey = new object(); private static ILPattern pattern = ILPattern.Sequence( ILPattern.Optional(OpCodes.Nop), ILPattern.OpCode(OpCodes.Ldarg_0), ILPattern.OpCode(OpCodes.Ldfld)); public override void Match(MatchContext context) { pattern.Match (context); if (!context.IsMatch) return; var match = GetLastMatchingInstruction(context); var field = (FieldInfo)match.Operand; context.AddData(BackingFieldKey, field); } } private static ILPattern _getterPattern = ILPattern.Sequence( ILPattern.Optional(ActivateCall()), BackingField(), ILPattern.Optional( OpCodes.Stloc_0, OpCodes.Br_S, OpCodes.Ldloc_0), ILPattern.OpCode(OpCodes.Ret)); private MethodInfo _method; private ReflectionMethodAnalyser(MethodInfo method) { _method = method; } private static MatchContext MatchGetter(MethodInfo method) { return ILPattern.Match(method, _getterPattern); } public void Run(QueryBuilderRecorder recorder) { RecordField(recorder, GetBackingField(_method)); } private static void RecordField(QueryBuilderRecorder recorder, FieldInfo field) { recorder.Add(ctx => { ctx.Descend(field.Name); ctx.PushDescendigFieldEnumType(field.FieldType.IsEnum ? field.FieldType : null); }); } private static FieldInfo GetBackingField(MethodInfo method) { return _fieldCache.Produce(method, ResolveBackingField); } private static FieldInfo ResolveBackingField(MethodInfo method) { var context = MatchGetter(method); if (!context.IsMatch) throw new QueryOptimizationException("Analysed method is not a simple getter"); return GetFieldFromContext (context); } private static FieldInfo GetFieldFromContext(MatchContext context) { object data; if (!context.TryGetData(BackingFieldPattern.BackingFieldKey, out data)) throw new NotSupportedException(); return (FieldInfo)data; } public static IMethodAnalyser FromMethod(MethodInfo method) { return new ReflectionMethodAnalyser(method); } } } #endif src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/CecilMethodAnalyser.cs000644 001750 001750 00000005047 11520622624 034561 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if CF || SILVERLIGHT using System; using System.Reflection; using Db4objects.Db4o.Internal.Caching; using Db4objects.Db4o.Linq.Caching; using Db4objects.Db4o.Linq.Internals; using Cecil.FlowAnalysis; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal class CecilMethodAnalyser : IMethodAnalyser { private static ICache4 _graphCache = CacheFactory.For(CacheFactory.New2QXCache(5)); private readonly Expression _queryExpression; private CecilMethodAnalyser(ActionFlowGraph graph) { if (graph == null) throw new ArgumentNullException("graph"); _queryExpression = QueryExpressionFinder.FindIn(graph); } public void Run(QueryBuilderRecorder recorder) { if (_queryExpression == null) throw new QueryOptimizationException("No query expression"); _queryExpression.Accept(new CodeQueryBuilder(recorder)); } public static IMethodAnalyser FromMethod(MethodInfo info) { return GetAnalyserFor(ResolveMethod(info)); } private static MethodDefinition ResolveMethod(MethodInfo info) { if (info == null) throw new ArgumentNullException("info"); var method = MetadataResolver.Instance.ResolveMethod(info); if (method == null) throw new QueryOptimizationException( string.Format("Cannot resolve method {0}", info)); return method; } private static IMethodAnalyser GetAnalyserFor(MethodDefinition method) { var graph = _graphCache.Produce(method, CreateActionFlowGraph); return new CecilMethodAnalyser(graph); } private static ActionFlowGraph CreateActionFlowGraph(MethodDefinition method) { return FlowGraphFactory.CreateActionFlowGraph(FlowGraphFactory.CreateControlFlowGraph(method)); } } } #endif src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/MetadataResolver.cs000644 001750 001750 00000007441 11520622624 034144 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if CF || SILVERLIGHT using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Db4objects.Db4o.Internal.Caching; using Db4objects.Db4o.Linq.Caching; using Mono.Cecil; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal class MetadataResolver { public static MetadataResolver Instance = new MetadataResolver(); private ICache4 _assemblyCache; private ICache4 _methodCache; private MetadataResolver() { _assemblyCache = CacheFactory.For(CacheFactory.New2QXCache(5)); _methodCache = CacheFactory.For(CacheFactory.New2QXCache(5)); } private AssemblyDefinition GetAssembly(Assembly assembly) { return _assemblyCache.Produce(assembly, ReadAssembly); } private static AssemblyDefinition ReadAssembly(Assembly assembly) { #if CF return AssemblyDefinition.ReadAssembly(assembly.ManifestModule.FullyQualifiedName); #elif SILVERLIGHT var reference = AssemblyNameReference.Parse(assembly.FullName); var streamInfo = System.Windows.Application.GetResourceStream(new Uri(reference.Name + ".dll", UriKind.Relative)); return AssemblyDefinition.ReadAssembly(streamInfo.Stream); #endif } #if CF private static string GetFullName(Type type) { if (type.DeclaringType != null) return type.FullName.Replace('+', '/'); return type.FullName; } private TypeDefinition GetType(Type type) { var assembly = GetAssembly(type.Assembly); return assembly.MainModule.GetType(GetFullName(type)); } private static bool ParameterMatch(ParameterDefinition parameter, ParameterInfo info) { return parameter.ParameterType.FullName == GetFullName(info.ParameterType); } private static bool ParametersMatch(IList parameters, ParameterInfo[] infos) { if (parameters.Count != infos.Length) return false; for (int i = 0; i < parameters.Count; i++) { if (!ParameterMatch(parameters[i], infos[i])) return false; } return true; } private static bool MethodMatch(MethodDefinition method, MethodInfo info) { if (method.Name != info.Name) return false; if (method.ReturnType.Name != info.ReturnType.Name) return false; return ParametersMatch(method.Parameters, info.GetParameters()); } private MethodDefinition GetMethod(MethodInfo method) { TypeDefinition type = GetType(method.DeclaringType); var matches = from MethodDefinition candidate in type.Methods where MethodMatch(candidate, method) select candidate; return matches.FirstOrDefault(); } #elif SILVERLIGHT private MethodDefinition GetMethod(MethodInfo method) { var assembly = GetAssembly(method.DeclaringType.Assembly); return (MethodDefinition)assembly.MainModule.LookupToken(method.MetadataToken); } #endif public MethodDefinition ResolveMethod(MethodInfo method) { if (method == null) throw new ArgumentNullException("method"); return _methodCache.Produce(method, GetMethod); } } } #endif src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/CodeQueryBuilder.cs000644 001750 001750 00000006423 11520622624 034110 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if CF || SILVERLIGHT using System; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil; using Db4objects.Db4o.Linq.Internals; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal class CodeQueryBuilder : AbstractCodeStructureVisitor { private readonly QueryBuilderRecorder _recorder; public CodeQueryBuilder(QueryBuilderRecorder recorder) { _recorder = recorder; } public override void Visit(ArgumentReferenceExpression node) { CannotOptimize(node); } public override void Visit(AssignExpression node) { CannotOptimize(node); } public override void Visit(BinaryExpression node) { CannotOptimize(node); } public override void Visit(CastExpression node) { CannotOptimize(node); } public override void Visit(FieldReferenceExpression node) { Type descendingEnumType = ResolveDescendingEnumType(node); _recorder.Add( ctx => { ctx.Descend(node.Field.Name); ctx.PushDescendigFieldEnumType(descendingEnumType); }); } public override void Visit(LiteralExpression node) { CannotOptimize(node); } public override void Visit(MethodInvocationExpression node) { CannotOptimize(node); } public override void Visit(MethodReferenceExpression node) { CannotOptimize(node); } public override void Visit(PropertyReferenceExpression node) { CannotOptimize(node); } public override void Visit(ThisReferenceExpression node) { CannotOptimize(node); } public override void Visit(UnaryExpression node) { CannotOptimize(node); } public override void Visit(VariableReferenceExpression node) { CannotOptimize(node); } private static void CannotOptimize(Expression expression) { throw new QueryOptimizationException(ExpressionPrinter.ToString(expression)); } private static Type ResolveDescendingEnumType(FieldReferenceExpression node) { var type = ResolveType(node.Field.FieldType); if (type == null) return null; if (!type.IsEnum) return null; return type; } private static Type ResolveType(TypeReference type) { var assemblyName = type.Module.Assembly.Name.FullName; var assembly = System.Reflection.Assembly.Load(assemblyName); if (assembly == null) return null; return assembly.GetType(NormalizeTypeName(type)); } private static string NormalizeTypeName(TypeReference type) { return type.FullName.Replace('/', '+'); } } } #endif src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/QueryExpressionFinder.cs000644 001750 001750 00000010364 11520622624 035215 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if CF || SILVERLIGHT using System.Collections.Generic; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal class QueryExpressionFinder { private ActionFlowGraph _graph; private Expression _queryExpression; private Dictionary _variables; private Expression QueryExpression { get { return _queryExpression; } } private QueryExpressionFinder(ActionFlowGraph graph) { _graph = graph; _variables = new Dictionary(); FindQueryExpression(); } public static Expression FindIn(ActionFlowGraph graph) { var finder = new QueryExpressionFinder(graph); return finder.QueryExpression; } private static ActionBlock GetFirstBlock(ActionFlowGraph graph) { if (graph.Blocks.Count < 1) return null; return graph.Blocks[0]; } private void FindQueryExpression() { var block = GetFirstBlock(_graph); while (block != null) { switch (block.ActionType) { case ActionType.Invoke: block = OnInvokeAction((InvokeActionBlock)block); break; case ActionType.ConditionalBranch: block = OnConditionalBranch((ConditionalBranchActionBlock)block); break; case ActionType.Branch: block = OnBranch((BranchActionBlock)block); break; case ActionType.Assign: block = OnAssign((AssignActionBlock)block); break; case ActionType.Return: block = OnReturn((ReturnActionBlock)block); break; } } } private ActionBlock OnInvokeAction(InvokeActionBlock block) { MethodInvocationExpression invocation = block.Expression; if (!IsActivateInvocation(invocation)) CannotOptimize(invocation); return block.Next; } private ActionBlock OnConditionalBranch(ConditionalBranchActionBlock block) { throw new QueryOptimizationException(); } private ActionBlock OnBranch(BranchActionBlock block) { return block.Target; } private ActionBlock OnAssign(AssignActionBlock block) { var assign = block.AssignExpression; var variable = assign.Target as VariableReferenceExpression; if (variable == null) CannotOptimize(assign); if (HasBeenAlreadyAssignedTo(variable)) CannotOptimize(assign.Expression); _variables.Add(GetVariableIndex(variable), assign.Expression); return block.Next; } private bool HasBeenAlreadyAssignedTo(VariableReferenceExpression variable) { return _variables.ContainsKey(GetVariableIndex(variable)); } private ActionBlock OnReturn(ReturnActionBlock block) { Expression expression = block.Expression; VariableReferenceExpression variable = expression as VariableReferenceExpression; _queryExpression = variable != null ? _variables[GetVariableIndex(variable)] : expression; return null; } private static bool IsActivateInvocation(MethodInvocationExpression invocation) { MethodReferenceExpression methodRef = invocation.Target as MethodReferenceExpression; if (null == methodRef) return false; return IsActivateMethod(methodRef.Method); } private static bool IsActivateMethod(MethodReference method) { return method.Name == "Activate"; } private static int GetVariableIndex(VariableReferenceExpression variable) { return variable.Variable.Index; } private static void CannotOptimize(Expression expression) { throw new QueryOptimizationException(ExpressionPrinter.ToString(expression)); } } } #endif src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/IMethodAnalyser.cs000644 001750 001750 00000001555 11520622624 033732 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using Db4objects.Db4o.Linq.Internals; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal interface IMethodAnalyser { void Run(QueryBuilderRecorder recorder); } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/MethodAnalyser.cs000644 001750 001750 00000001777 11520622624 033706 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System.Reflection; namespace Db4objects.Db4o.Linq.CodeAnalysis { internal static class MethodAnalyser { public static IMethodAnalyser FromMethod(MethodInfo method) { #if CF || SILVERLIGHT return CecilMethodAnalyser.FromMethod(method); #else return ReflectionMethodAnalyser.FromMethod(method); #endif } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Caching/000755 001750 001750 00000000000 11520622070 027375 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Caching/CacheFactory.cs000644 001750 001750 00000007171 11520622624 032272 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using Db4objects.Db4o.Foundation; using Db4objects.Db4o.Internal.Caching; namespace Db4objects.Db4o.Linq.Caching { /// /// Generic wrappers for . /// /// /// public class CacheFactory { public static ICache4 For(ICache4 cache4) { return new Cache4CachingStrategy(cache4); } public static ICache4 For(ICache4 cache4, IEqualityComparer comparer) { return new Cache4CachingStrategyWithComparer(cache4, comparer); } } internal class Cache4CachingStrategy : ICache4 { private readonly ICache4 _cache4; public Cache4CachingStrategy(ICache4 cache4) { _cache4 = cache4; } virtual public TValue Produce(TKey key, Func producer) { return (TValue) Cache4Produce(key, producer); } virtual protected object Cache4Produce(object key, Func producer) { return Cache4Produce(key, new Function4Func(producer)); } virtual protected object Cache4Produce(object key, IFunction4 producer) { return _cache4.Produce(key, producer, null); } } internal class Cache4CachingStrategyWithComparer : Cache4CachingStrategy { private readonly IEqualityComparer _comparer; public Cache4CachingStrategyWithComparer(ICache4 cache4, IEqualityComparer comparer) : base(cache4) { _comparer = comparer; } public override TValue Produce(TKey key, Func producer) { return (TValue) Cache4Produce(new ComparableKey(_comparer, key), new UnwrappingProducer(producer)); } internal class UnwrappingProducer : IFunction4 { private readonly Func _producer; public UnwrappingProducer(Func producer) { _producer = producer; } #region Implementation of IFunction4 public object Apply(object arg) { return _producer(((ComparableKey) arg).Key); } #endregion } internal class ComparableKey { private readonly IEqualityComparer _comparer; private readonly TKey _key; public ComparableKey(IEqualityComparer comparer, TKey key) { _comparer = comparer; _key = key; } public TKey Key { get { return _key; } } public override bool Equals(object obj) { return _comparer.Equals(_key, ((ComparableKey) obj)._key); } public override int GetHashCode() { return _comparer.GetHashCode(_key); } } } internal class Function4Func : IFunction4 { private readonly Func _func; public Function4Func(Func func) { _func = func; } public object Apply(object arg) { return _func((T) arg); } } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Caching/ICache4.cs000644 001750 001750 00000001521 11520622624 031130 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; namespace Db4objects.Db4o.Linq.Caching { public interface ICache4 { TValue Produce(TKey key, Func producer); } } src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Caching/TracingCacheDecorator.cs000644 001750 001750 00000003136 11520622624 034033 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Diagnostics; #if !SILVERLIGHT namespace Db4objects.Db4o.Linq.Caching { public class TracingCacheDecorator : ICache4 { private readonly ICache4 _delegate; public TracingCacheDecorator(ICache4 @delegate) { _delegate = @delegate; } public TValue Produce(TKey key, Func producer) { var hit = true; var result = _delegate.Produce(key, delegate(TKey newKey) { hit = false; return producer(newKey); }); TraceCacheHitMiss(key, hit); return result; } private void TraceCacheHitMiss(TKey key, bool hit) { if (hit) Trace.WriteLine("Cache hit: " + key); else Trace.WriteLine("Cache miss: " + key); } } } #endif db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/ILinqQueryMonitor.cs000644 001750 001750 00000001632 11520622624 032011 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Linq { /// /// commonConfiguration.Environment.Add(new MyLinqQueryMonitor()); /// public interface ILinqQueryMonitor { void OnOptimizedQuery(); void OnUnoptimizedQuery(); } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/Db4oLinqQueryExtensions.cs000644 001750 001750 00000011262 11520622624 033121 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Db4objects.Db4o.Linq.Expressions; using Db4objects.Db4o.Linq.Internals; namespace Db4objects.Db4o.Linq { /// /// A class that defines some standard linq query operations /// that can be optimized. /// public static class Db4oLinqQueryExtensions { public static IDb4oLinqQuery Where(this IDb4oLinqQuery self, Expression> expression) { return Process(self, query => new WhereClauseVisitor().Process(expression), data => data.UnoptimizedWhere(expression.Compile()) ); } public static int Count(this IDb4oLinqQuery self) { if (self == null) throw new ArgumentNullException("self"); var query = self as Db4oQuery; if (query != null) return query.Count; return Enumerable.Count(self); } private static IDb4oLinqQuery Process( IDb4oLinqQuery query, Func, IQueryBuilderRecord> queryProcessor, Func, IEnumerable> fallbackProcessor) { if (query == null) { throw new ArgumentNullException("query"); } var candidate = query as Db4oQuery; if (candidate == null) { return new UnoptimizedQuery(fallbackProcessor((IDb4oLinqQueryInternal) EnsureDb4oQuery(query))); } try { IQueryBuilderRecord record = queryProcessor(candidate); return new Db4oQuery(candidate, record); } catch (QueryOptimizationException) { return new UnoptimizedQuery(fallbackProcessor(candidate)); } } private static IDb4oLinqQuery EnsureDb4oQuery(IDb4oLinqQuery query) { var placeHolderQuery = query as PlaceHolderQuery; if (placeHolderQuery == null) { return query; } return new Db4oQuery(placeHolderQuery.QueryFactory); } private static IDb4oLinqQuery ProcessOrderBy( IDb4oLinqQuery query, OrderByClauseVisitorBase visitor, Expression> expression, Func, IEnumerable> fallbackProcessor) { return Process(query, q => visitor.Process(expression), fallbackProcessor); } public static IDb4oLinqQuery OrderBy(this IDb4oLinqQuery self, Expression> expression) { return ProcessOrderBy(self, new OrderByAscendingClauseVisitor(), expression, data => data.OrderBy(expression.Compile()) ); } public static IDb4oLinqQuery OrderByDescending(this IDb4oLinqQuery self, Expression> expression) { return ProcessOrderBy(self, new OrderByDescendingClauseVisitor(), expression, data => data.OrderByDescending(expression.Compile()) ); } public static IDb4oLinqQuery ThenBy(this IDb4oLinqQuery self, Expression> expression) { return ProcessOrderBy(self, new OrderByAscendingClauseVisitor(), expression, data => data.UnoptimizedThenBy(expression.Compile()) ); } public static IDb4oLinqQuery ThenByDescending(this IDb4oLinqQuery self, Expression> expression) { return ProcessOrderBy(self, new OrderByDescendingClauseVisitor(), expression, data => data.UnoptimizedThenByDescending(expression.Compile()) ); } public static IDb4oLinqQuery Select(this IDb4oLinqQuery self, Func selector) { var placeHolderQuery = self as PlaceHolderQuery; if (placeHolderQuery != null) return new Db4oQuery(placeHolderQuery.QueryFactory); return new UnoptimizedQuery(Enumerable.Select(self, selector)); } #if !CF_3_5 public static IDb4oLinqQueryable AsQueryable(this IDb4oLinqQuery self) { return new Db4oQueryable(self); } #endif } } db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/IDb4oLinqQueryable.cs000644 001750 001750 00000002344 11520622624 031777 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if !CF_3_5 using System.Linq; namespace Db4objects.Db4o.Linq { /// /// IDb4oLinqQueryable is the query type of Linq to db4o when working with an API requiring /// a LINQ provider implementing IQueryable. /// The type of the objects that are queried from the database. /// public interface IDb4oLinqQueryable : IDb4oLinqQueryable, IOrderedQueryable { } public interface IDb4oLinqQueryable : IOrderedQueryable { IDb4oLinqQuery GetQuery(); } } #endifdb4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/ExtensionAttribute.cs000644 001750 001750 00000001547 11520622624 026570 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #if CF namespace System.Runtime.CompilerServices { public class ExtensionAttribute : Attribute { static ExtensionAttribute() { } public ExtensionAttribute() { } } } #endif db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq-Silverlight-2008.csproj000644 001750 001750 00000016043 11520622064 032153 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {96E9DCEB-D739-419F-8346-1BC2EE86F562} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4objects.Db4o.Linq Db4objects.Db4o.Linq v3.5 false true true true ../db4objects.snk true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 False ..\Libs\silverlight\Cecil.FlowAnalysis.dll False ..\Libs\silverlight\Mono.Cecil.dll {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Makefile000644 001750 001750 00000000313 11520622056 024026 0ustar00directhexdirecthex000000 000000 include ../../db4o.net/include.mk OUTDIR = ../../db4o.net/bin TARGET = library ASSEMBLY = Db4objects.Db4o.Linq.dll REFERENCES = -r:$(OUTDIR)/$(CORE) -r:$(OUTDIR)/$(CECIL) -r:$(OUTDIR)/$(FLOWANALYSIS) db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Properties/000755 001750 001750 00000000000 11520622060 024520 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Properties/AssemblyInfo.cs000644 001750 001750 00000002561 11520622624 027454 0ustar00directhexdirecthex000000 000000 /* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Reflection; using System.Runtime.InteropServices; using System.Security; [assembly: AssemblyTitle("Db4objects.Db4o.Linq")] [assembly: AssemblyDescription("Db4objects.Db4o.Linq 8.0.184.15484 (.NET)")] [assembly: AssemblyConfiguration(".NET")] [assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] [assembly: AssemblyProduct("db4o - database for objects")] [assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible (false)] [assembly: AssemblyVersion("8.0.184.15484")] #if !CF &&!SILVERLIGHT [assembly: AllowPartiallyTrustedCallers] #endif [assembly: CLSCompliant(true)] db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq-2008.csproj000644 001750 001750 00000014155 11520622042 027657 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {23531440-0922-43EB-A483-6592FFC2F093} Library Properties Db4objects.Db4o.Linq Db4objects.Db4o.Linq v3.5 512 true ../db4objects.snk true full false bin\Debug\ DEBUG;TRACE prompt 4 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE prompt 4 1591;1572;1573;1574;0419; False ..\Libs\net-3.5\Mono.Reflection.dll 3.5 {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} Db4objects.Db4o-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq-Silverlight-2010.csproj000644 001750 001750 00000016434 11520622064 032150 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 8.0.50727 2.0 {2E56236C-E595-4DFF-9B9E-0E0509D29A4E} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4objects.Db4o.Linq Db4objects.Db4o.Linq Silverlight v4.0 $(TargetFrameworkVersion) false true true true ../db4objects.snk v3.5 true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 ..\Libs\silverlight\Cecil.FlowAnalysis.dll ..\Libs\silverlight\Mono.Cecil.dll {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2010 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq-CF-2008.csproj000644 001750 001750 00000017140 11520622070 030143 0ustar00directhexdirecthex000000 000000 Debug AnyCPU 9.0.30729 2.0 {4F7E0FA5-7023-4C49-90DD-BC6A1DCC733D} Library Properties Db4objects.Db4o.Linq Db4objects.Db4o.Linq {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 Db4objects.Db4o.Linq v3.5 Pocket PC 2003 true ../db4objects.snk true full false bin\Debug\ TRACE;DEBUG;PocketPC;CF_3_5,CF true true prompt 512 4 Off 1591;1572;1573;1574;0419; pdbonly true bin\Release\ TRACE;PocketPC;CF_3_5,CF true true prompt 512 4 Off 1591;1572;1573;1574;0419; False ..\Libs\compact-2.0\Cecil.FlowAnalysis.dll False ..\Libs\compact-2.0\Mono.Cecil.dll {95FD1C64-F1A3-4C8A-B170-D518E899B2FE} Db4objects.Db4o-CF-2008 {92FFA693-E97C-42AF-B479-E311BB4A7321} System.Linq.Expressions-CF-2008 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Silverlight.TestStart/000755 001750 001750 00000000000 11520622060 025711 5ustar00directhexdirecthex000000 000000 src/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart-2010.csproj000644 001750 001750 00000016113 11520622040 036435 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg v3.5 true ../db4objects.snk Debug AnyCPU 9.0.30729 2.0 {A639AD3D-08FB-41D5-A770-B8BE540C369D} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Db4objects.Db4o.Silverlight.TestStart Db4objects.Db4o.Silverlight.TestStart v4.0 true true true Db4objects.Db4o.Silverlight.TestStart.xap Properties\AppManifest.xml Db4objects.Db4o.Silverlight.TestStart.App TestPage.html true true false true OnBuildSuccess Silverlight $(TargetFrameworkVersion) 3.5 true full false Bin\Debug DEBUG;TRACE;SILVERLIGHT true true prompt 4 pdbonly true Bin\Release TRACE;SILVERLIGHT true true prompt 4 App.xaml MainPage.xaml Designer MSBuild:MarkupCompilePass1 MSBuild:Compile Designer Designer MSBuild:MarkupCompilePass1 MSBuild:Compile Designer Always {C53361EB-4B4F-4D0F-9ECC-8F216F15A705} Db4objects.Db4o.Linq.Tests-Silverlight-2010 {97B6DEA6-255B-4B49-8973-38943AC2E70C} Db4objects.Db4o.Optional-Silverlight-2010 {C388ABDD-CB2C-4438-8942-C3A935AC8E2D} Db4objects.Db4o.Tests-Silverlight-2010 {76FFA4C5-6CC6-4C8C-BACF-B1C76AE0CA65} Db4objects.Db4o-Silverlight-2010 {13B5E015-9250-4E70-939D-56233D43D8C3} Db4oUnit.Extensions-Silverlight-2010 {C74364D8-A04A-4CF9-801D-D1811D49E72A} Db4oUnit-Silverlight-2010 xcopy $(ProjectDir)Db4objects.Db4o.Silverlight.TestStart\TestPage.html /Y src/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart/000755 001750 001750 00000000000 11520622066 034641 5ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsgsrc/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart/MainPage.xaml.cs000644 001750 001750 00000004771 11520622624 037622 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.IO.IsolatedStorage; using System.Threading; using System.Windows.Browser; using Db4oUnit; using Db4oUnit.Extensions; using Db4oUnit.Extensions.Fixtures; namespace Db4objects.Db4o.Silverlight.TestStart { public partial class MainPage { public MainPage() { InitializeComponent(); ThreadPool.QueueUserWorkItem(unused => TestRunnerEntry()); } private void TestRunnerEntry() { try { Type[] testCases = new[] { typeof(Tests.Silverlight.AllTests), typeof(Linq.Tests.AllTests), typeof(Tests.Common.AllTests), typeof(Tests.CLI1.AllTests), typeof(Tests.CLI2.AllTests), }; InitializeVersion(); new TestRunner(SilverlightSuite(testCases)).Run(new SilverlightTestListener(Dispatcher)); Complete(); } catch(Exception ex) { AppendException(ex); } } private void InitializeVersion() { var version = Environment.Version.ToString(); Dispatcher.BeginInvoke(() => HtmlPage.Window.Eval(string.Format("initialize('{0}');", version))); } private void Complete() { Dispatcher.BeginInvoke(() => HtmlPage.Window.Eval("completed();")); } private void AppendException(Exception exception) { Dispatcher.BeginInvoke(() => HtmlPage.Window.Eval("appendException(\"" + exception.ToJScriptString() + "\");")); } private static Db4oTestSuiteBuilder SilverlightSuite(params Type[] testCases) { return new Db4oTestSuiteBuilder(new SilverlightFixture(), testCases); } private void OnIncreaseDiskQuotaClick(object sender, System.Windows.RoutedEventArgs e) { var isolatedStorageManager = IsolatedStorageFile.GetUserStoreForApplication(); isolatedStorageManager.IncreaseQuotaTo(1024*1024*100); } } } src/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart/App.xaml000644 001750 001750 00000000500 11520622042 036231 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg src/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart/JScriptExtensions.cs000644 001750 001750 00000001711 11520622624 040626 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ namespace Db4objects.Db4o.Silverlight.TestStart { public static class JScriptExtensions { public static string ToJScriptString(this object value) { return value.ToString() .Replace("\"", @"\\""") .Replace("\r", @"\r") .Replace("\n", @"\n"); } } } src/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart/App.xaml.cs000644 001750 001750 00000003470 11520622624 036654 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Diagnostics; using System.Windows; using System.Windows.Browser; namespace Db4objects.Db4o.Silverlight.TestStart { public partial class App { public App() { Startup += Application_Startup; UnhandledException += Application_UnhandledException; InitializeComponent(); } private void Application_Startup(object sender, StartupEventArgs e) { RootVisual = new MainPage(); } private static void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (!Debugger.IsAttached) { MessageBox.Show(e.ToString()); e.Handled = true; Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); } } private static void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e) { try { string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");"); } catch (Exception) { } } } } Db4objects.Db4o.Silverlight.TestStart/SilverlightTestListener.cs000644 001750 001750 00000007002 11520622624 042031 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg/src/Db4objects.Db4o.Silverlight.TestStart/* This file is part of the db4o object database http://www.db4o.com Copyright (C) 2004 - 2010 Versant Corporation http://www.versant.com db4o is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. db4o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Browser; using System.Windows.Threading; using Db4oUnit; namespace Db4objects.Db4o.Silverlight.TestStart { public class SilverlightTestListener : ITestListener { public SilverlightTestListener(Dispatcher dispatcher) { _dispatcher = dispatcher; } public void RunStarted() { Run("append", "Tests started..."); _startTime = DateTime.Now; } public void TestStarted(ITest test) { NewTest(test.Label()); } public void TestFailed(ITest test, Exception failure) { _failures.Add(new TestFailure(test.Label(), failure)); MarkLastAsError(); } public void Failure(String msg, Exception failure) { _failures.Add(new TestFailure(msg, failure)); } public void RunFinished() { AppendTestsResult(); Append(FailuresMessage()); } private void Append(string message) { Run("append", message); } private void AppendTestsResult() { Run("appendTestsResult", DateTime.Now.Subtract(_startTime).TotalSeconds); } private void NewTest(string message) { _latestAppended = Run("newTest", message); } private static string RemoveExtraCommaAtStart(string arguments) { return arguments.Remove(0, 1); } private void Dispatch(Action action) { _dispatcher.BeginInvoke(action); } private void MarkLastAsError() { _dispatcher.BeginInvoke(() => HtmlPage.Window.Invoke("markAsFailure", _latestAppended)); } private string FailuresMessage() { int count = 1; return _failures.Aggregate(new StringBuilder(), (acc, failure) => acc.AppendFormat("{0}) {1} {2}

", count++, failure.TestLabel, failure.Reason)).Replace("\r\n", "
").ToJScriptString(); } private object Run(string functionName, params object[] args) { Dispatch(delegate { string code = functionName + "(" + ToStringArgumentList(args) + ");"; object result = HtmlPage.Window.Eval(code); if (result != null) { _latestAppended = result; } }); return _latestAppended; } private static string ToStringArgumentList(IEnumerable objects) { string arguments = objects.Aggregate("", (acc, current) => acc + "," + AddQuotes(RemoveInternalQuotes(current.ToJScriptString()))); return RemoveExtraCommaAtStart(arguments); } private static string RemoveInternalQuotes(string source) { return source.Replace('"', '\''); } private static string AddQuotes(object item) { return "\"" + item + "\""; } private object _latestAppended; private DateTime _startTime; private readonly IList _failures = new List(); private readonly Dispatcher _dispatcher; } } src/Db4objects.Db4o.Silverlight.TestStart/Db4objects.Db4o.Silverlight.TestStart/MainPage.xaml000644 001750 001750 00000001010 11520622042 037167 0ustar00directhexdirecthex000000 000000 db4o-8.0.184.15484+dfsg