Compare commits
690 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fae55e44e | |||
| a8ca3a89bd | |||
| 765f959f20 | |||
| 2cf90477ed | |||
| 6ca6a08233 | |||
| 0119f1eb1b | |||
| cd4f66e7c5 | |||
| 3fdc0e5361 | |||
| 4bfb8569c8 | |||
| df9a887032 | |||
| 1e0a4690fc | |||
| 52163494db | |||
| 8416764a83 | |||
| 2d3eb8c208 | |||
| aa84a3f7f2 | |||
| 3594693f4b | |||
| c573459626 | |||
| b99de245bf | |||
| 222723b8fe | |||
| f758b33da5 | |||
| eeb0e0026a | |||
| 082dacf737 | |||
| afc2fd9420 | |||
| ff6715d42a | |||
| b776675ac8 | |||
| 1e21671b62 | |||
| 59184981cb | |||
| 0632ffb93d | |||
| 034aa6d8f9 | |||
| 1484fba1ad | |||
| 82fc1a5304 | |||
| f0aab6ae81 | |||
| 9ac325c1a4 | |||
| 8c257d39f9 | |||
| 76f040aef4 | |||
| 721f813d1e | |||
| 7ed5a6f706 | |||
| 35a698cdc9 | |||
| 6c9e82e735 | |||
| f7ddb1ed49 | |||
| c0fd974cc1 | |||
| e9c4a031c9 | |||
| 123e65c55f | |||
| e5e4e7b685 | |||
| 88795b86fd | |||
| 378a544c1a | |||
| a159b50c05 | |||
| 3891e46549 | |||
| e7bcc642a9 | |||
| 4983990d39 | |||
| e9a496df4f | |||
| 2f6dada481 | |||
| 580123cb87 | |||
| de0e47d7ef | |||
| ff5dc324fe | |||
| 096c5ad69f | |||
| eba7582a97 | |||
| 0cf2a1fc2a | |||
| 77ee87178e | |||
| a6997a5cb7 | |||
| ff3fc5d825 | |||
| 3b9bf7b0f9 | |||
| 3882e1984d | |||
| b32ea68fd0 | |||
| eb2db791b8 | |||
| 158f4d0614 | |||
| 7a38970cf4 | |||
| 7f6d8b6bdd | |||
| 22fb7e1706 | |||
| 12b1168de9 | |||
| 01290f8174 | |||
| 26a7bf8187 | |||
| ba1d0fa193 | |||
| 97355bde6f | |||
| ed35f234de | |||
| c874fa6507 | |||
| ba387598ed | |||
| 3ff1b01e46 | |||
| 36e803713c | |||
| a3e7f644de | |||
| 1586f1679a | |||
| 809badd1cf | |||
| da92ece774 | |||
| a531afb819 | |||
| 1d6009e3c7 | |||
| 8dfeb1e616 | |||
| 1b086e2267 | |||
| 1f86d8c562 | |||
| 25b9262cf1 | |||
| 1012a4814d | |||
| bae41cde14 | |||
| b3260f05c0 | |||
| e33a79ac65 | |||
| c4dbabf654 | |||
| 423643d66c | |||
| 4ccb655f73 | |||
| c8330d60f9 | |||
| a9aa3a04b5 | |||
| 0bffa8e3f4 | |||
| 436322f58c | |||
| e90c46dd78 | |||
| deda2534f8 | |||
| 8112c13857 | |||
| 57792de185 | |||
| e1f93029a5 | |||
| f64e0c7eb7 | |||
| bf024e9011 | |||
| 036b888d30 | |||
| 1838a8dac5 | |||
| 205bf5fe4e | |||
| a50e192ab7 | |||
| 9684255e6e | |||
| 72790d74f5 | |||
| bb70bee6ae | |||
| 0430e7966c | |||
| 2e9a52b1f8 | |||
| db4ed70d70 | |||
| e6ccd8a5b5 | |||
| a9781d79e2 | |||
| 7ae8b28466 | |||
| 29a4cb8b71 | |||
| ffb39de003 | |||
| 527375b238 | |||
| a4ed0e266c | |||
| 1929f60ea8 | |||
| b9cc2efc8c | |||
| eadb1bb194 | |||
| 30be665a40 | |||
| bad284515c | |||
| 5b660d95f1 | |||
| 106ac44e64 | |||
| 64bb7e1db0 | |||
| 25b9ca3b0e | |||
| b928170103 | |||
| e25ee246fb | |||
| 8e8ec41dae | |||
| fb34c4716a | |||
| 29bf61b1f2 | |||
| 9803309e34 | |||
| 3a539629dc | |||
| 74b970d586 | |||
| 518898b04b | |||
| a773e0a018 | |||
| 99fe89addc | |||
| 668d4f9f91 | |||
| 90e73cb89f | |||
| dcd6477030 | |||
| 13b73231de | |||
| 50a70c28df | |||
| 7d5589118f | |||
| c39b698d4c | |||
| 103efbdc27 | |||
| 3d51dd767b | |||
| e22988e435 | |||
| 9736aaafaa | |||
| bf3fa20a53 | |||
| f936f8b0dd | |||
| 1bd20c9b06 | |||
| 099b713947 | |||
| 165d9c7dff | |||
| 09400be6e0 | |||
| 7934ba7ec4 | |||
| 7edbc34e6c | |||
| 60b6608289 | |||
| 792599a42f | |||
| 7610ee5f8b | |||
| eab9be4ef7 | |||
| e48a030aab | |||
| e207b1f1e1 | |||
| fd3540f92d | |||
| b9d7f0c5a5 | |||
| 3d76614a78 | |||
| de0e6f3179 | |||
| 39edb9b7e2 | |||
| a638488eb7 | |||
| a2a539f7db | |||
| 6768bb4793 | |||
| 19c2841576 | |||
| 71aa248a4e | |||
| eeaef5ac5c | |||
| bea50f4562 | |||
| ff337457f8 | |||
| 49b5ddf850 | |||
| b449b8762b | |||
| 13e555f50b | |||
| 48c809a797 | |||
| 55c7f72d8e | |||
| 8612113fc0 | |||
| 69b0c7cf09 | |||
| 37a97a2e7c | |||
| 5f4eaef4a2 | |||
| 44f5c3a34f | |||
| a33ae696a2 | |||
| 2705efb809 | |||
| 648d631151 | |||
| 27c0c4d64e | |||
| 52cf559536 | |||
| c9b0362c62 | |||
| 11e5bdf556 | |||
| 3d0be3836c | |||
| 2bc33e0115 | |||
| 8576d9c67e | |||
| a0651f4383 | |||
| 9452d5fd09 | |||
| 1f40d726de | |||
| 2699611ba3 | |||
| 43795f0007 | |||
| b1fa06bfe8 | |||
| 4dc22b6ce4 | |||
| d4ab60f8af | |||
| 883277125a | |||
| 8edfc0ffdd | |||
| ff961abaab | |||
| b2414c1ab8 | |||
| 9dde86d591 | |||
| b4ce4fbdef | |||
| 4285484c1b | |||
| 2fd299ebfc | |||
| f545f293b1 | |||
| b745c0ae90 | |||
| f2efff5411 | |||
| 9ef5890636 | |||
| bc9fd04a36 | |||
| 185c5d78f1 | |||
| 3ea9963166 | |||
| ab40822a98 | |||
| dffce76e29 | |||
| d1e02f506c | |||
| 5e18d13178 | |||
| 1dfca6836d | |||
| dbbdd16bb9 | |||
| 74362fba23 | |||
| 112502cf18 | |||
| 1db7f808c9 | |||
| 762cca145f | |||
| 65dc5eaeee | |||
| 4f81e06d3d | |||
| 6b74b75b6f | |||
| 98e53b3d74 | |||
| a1f01f9d5c | |||
| f5d8cb0275 | |||
| 0d8b65caea | |||
| 70285991bb | |||
| a336eaa4a1 | |||
| fdefe993b7 | |||
| ba0e72a1c1 | |||
| c5710277a5 | |||
| 5cd2d568e3 | |||
| 9c89a56d8d | |||
| 9ba7664f78 | |||
| 4b87a5c2d3 | |||
| f0699afb6e | |||
| b4d5658d45 | |||
| d485c3da97 | |||
| 1214082997 | |||
| 1a56e6693a | |||
| c6b7f20dab | |||
| 5cc55ad6e2 | |||
| a55fedab0a | |||
| 0e12f14a4a | |||
| 3e25b71d9e | |||
| 63de9e6691 | |||
| b9ea85d29d | |||
| d0787e92fe | |||
| ffe9953c43 | |||
| 99a9f1ab87 | |||
| 7def26a489 | |||
| a76ffe8daf | |||
| 259fbcb8f0 | |||
| ee9f91b5cf | |||
| db3f21429e | |||
| 033692d7ee | |||
| 23146cb12a | |||
| 04b9607741 | |||
| 0e392b398c | |||
| 5914690ad8 | |||
| c4aa9095f2 | |||
| 79ce586c8b | |||
| 8fba03c05d | |||
| 2fdcb9164a | |||
| 7404a1f93d | |||
| c8b8b28e9b | |||
| 5bd2571395 | |||
| c0cd157e60 | |||
| ac2f9b172c | |||
| b8e4a73c3b | |||
| 63192f3a65 | |||
| 727f62d418 | |||
| 68c4255a51 | |||
| 187af3e361 | |||
| c6f29a50d6 | |||
| d07212c89b | |||
| 28c55320a1 | |||
| cb0dd70434 | |||
| fd58017e97 | |||
| 928d92fce4 | |||
| 09408b898e | |||
| d1b05332c5 | |||
| 836b0f39c2 | |||
| 1b01386673 | |||
| 2a09f02afb | |||
| ee95434cea | |||
| caad0afed8 | |||
| fe08e7fc2f | |||
| 4ad96b49e7 | |||
| 9a1bb4a2dd | |||
| c39f902ed5 | |||
| b7dc052cb2 | |||
| 0c77114cd5 | |||
| 222a5237b0 | |||
| de55cb8392 | |||
| df164ee618 | |||
| 21b0687a57 | |||
| 9310efa280 | |||
| a41b55a9e6 | |||
| af2d8a4755 | |||
| d48e339b81 | |||
| 9b6d498cf7 | |||
| 62d365573f | |||
| 04bf011fcd | |||
| f3b7a8a581 | |||
| 5d62902684 | |||
| 82d645a0f7 | |||
| a8936de638 | |||
| a765f36d24 | |||
| 6b691eb461 | |||
| 046da1a8ce | |||
| ca7abd6c78 | |||
| 452688b2bb | |||
| 7cc0f2a514 | |||
| a2251fe062 | |||
| 3d0684eac0 | |||
| a8fafaa194 | |||
| 2b8a6e532e | |||
| d497659f1f | |||
| 0cafeac6eb | |||
| 4516305f3c | |||
| 04c8390a4f | |||
| fc94d92b37 | |||
| 84171c6b98 | |||
| 3ff88bc4fa | |||
| 4b54edf660 | |||
| 1bc9d1d9c3 | |||
| b5cbe63a4e | |||
| 4882df43bd | |||
| cb03178d99 | |||
| 361fa8836b | |||
| 194ebb57b9 | |||
| 5effe5015e | |||
| ee2943b9fb | |||
| a3b03988b3 | |||
| 6d5f7c4293 | |||
| cc32e73235 | |||
| 92ef4d8055 | |||
| e57e2f5b5f | |||
| 0b4efe4eeb | |||
| c250fa560e | |||
| 6eeae52333 | |||
| c38c18fed8 | |||
| 0af47963c6 | |||
| b017e8690a | |||
| 916e442ee4 | |||
| ecae9c47b7 | |||
| 836a99128f | |||
| abefbc7581 | |||
| 365addedf4 | |||
| 44f5439a2c | |||
| 8a9680e75c | |||
| ae0991bc67 | |||
| 0caaaa500c | |||
| 36c66e676a | |||
| a14baeb111 | |||
| 5b4d8ed6f3 | |||
| 25ea4003f9 | |||
| 30cef671dc | |||
| 250e627b1d | |||
| 5b00501d21 | |||
| 06e5350c43 | |||
| ba530061a0 | |||
| 89ae3bc143 | |||
| 484afccf89 | |||
| 3951f59d09 | |||
| 2589ec8367 | |||
| a6aeada197 | |||
| cd8c998ebf | |||
| 2a9e32e8fd | |||
| 603724ddd6 | |||
| 902cfc5a22 | |||
| 2cb544591b | |||
| db7aa99b85 | |||
| 031ceccf5d | |||
| 7127706c43 | |||
| d078ef8f5e | |||
| 289b9743c5 | |||
| eda9ba07f4 | |||
| 1b1b5c047c | |||
| fa5b9e5689 | |||
| 6948d70b75 | |||
| 3f9b022ae4 | |||
| 990ab7f87f | |||
| 861198eec9 | |||
| c26df8da6f | |||
| b5aefdce04 | |||
| adfb7cfaa4 | |||
| 0a88ba05c8 | |||
| 9ee295d49e | |||
| 1e02d85fca | |||
| 7173b44b4f | |||
| 69f6edadb3 | |||
| d1dc2331f8 | |||
| bb2f3a1732 | |||
| 4b29d7ba2e | |||
| d503deb8c5 | |||
| 0859b92aaf | |||
| b409740da5 | |||
| a888e0564c | |||
| fef96e8b43 | |||
| 429522a0bc | |||
| e9b2261aab | |||
| 02adb6e112 | |||
| 695d26434c | |||
| 00d408e6bc | |||
| 0498161367 | |||
| 0d3d4693b4 | |||
| a19de645e4 | |||
| f0a53ea9c0 | |||
| fbcabc94f2 | |||
| de9a27db10 | |||
| d494b061f3 | |||
| ebc8443e70 | |||
| 48ee59b94e | |||
| 560dcad90a | |||
| 7498b2f994 | |||
| df4f92197a | |||
| 13b1191aad | |||
| adaec42982 | |||
| b6d5b7d603 | |||
| 93d7cf4dc3 | |||
| e9f2546c2a | |||
| 007c4d5862 | |||
| f3621aa743 | |||
| 46cf4398a0 | |||
| 1599f493fa | |||
| b5d79ebb74 | |||
| 1cc8367fa9 | |||
| 7e5087ae7d | |||
| d6f9909bec | |||
| 0c42596dc8 | |||
| 9b4da4c8f8 | |||
| cfc81d0e84 | |||
| 00e10deecb | |||
| 46e67e4a92 | |||
| 520a7f238d | |||
| 3c41871e59 | |||
| 8cf9c1ba97 | |||
| e2d806f5d9 | |||
| 7a47d63b48 | |||
| 596c4ac329 | |||
| 8ad8a3239a | |||
| c0fa011cc3 | |||
| 4648a8c103 | |||
| 2df05da7fc | |||
| 87947871d1 | |||
| 87fee572ff | |||
| e00c0fc447 | |||
| 7137c57ac9 | |||
| d68b4d97f6 | |||
| 89f7a3ec63 | |||
| 96a62b57fb | |||
| 7092a9ccbb | |||
| e9ea9b5e1b | |||
| fd1efb29ec | |||
| cf4781153e | |||
| 46687429fb | |||
| ce7aa43aa7 | |||
| ebed142cd5 | |||
| 76e5304233 | |||
| d162aba14a | |||
| 387398b044 | |||
| 635b8bd82e | |||
| f2071379fc | |||
| ec075f5807 | |||
| eb8875066c | |||
| dca90e6316 | |||
| 2a47b384d2 | |||
| 29e5872a0f | |||
| df31fafec5 | |||
| 5f28f279e0 | |||
| 828dc64035 | |||
| 1d9e445a42 | |||
| 1aa137e9da | |||
| 042eb47c17 | |||
| a6556d0195 | |||
| 0b74164a8e | |||
| 807b32fb0d | |||
| 62be1b1267 | |||
| bda3fbc698 | |||
| 85ae7e764f | |||
| c744e47665 | |||
| 3daa624627 | |||
| 9a7894df76 | |||
| d8af1aaf7b | |||
| f2d105d8b9 | |||
| c93193c5c8 | |||
| 6734420c6f | |||
| fd795e14c6 | |||
| d622f76393 | |||
| d4fc82dae1 | |||
| d4058bd81f | |||
| bc824ba66a | |||
| 4201286038 | |||
| e333ad2b23 | |||
| a8eeabb73d | |||
| b06620f56e | |||
| e8524963dd | |||
| 5b0a8c0668 | |||
| 5d931d1146 | |||
| 879c77c68d | |||
| e71dd3008d | |||
| 597c888d36 | |||
| ef4c02f759 | |||
| 452a0a43b0 | |||
| c3ccf3a609 | |||
| 60bbede408 | |||
| 0751aff31f | |||
| a2ea20de70 | |||
| 3bfa1be60c | |||
| 8d38cf3c44 | |||
| a3a9ab069a | |||
| da908501e5 | |||
| 995ed22401 | |||
| c9cd4c721c | |||
| c059c14d7a | |||
| 04c9771978 | |||
| 9c8b5cd97e | |||
| 8bb447065c | |||
| 1d0299af89 | |||
| 5b8beceea8 | |||
| e4568520a9 | |||
| cbba628eaf | |||
| c2d0e255df | |||
| e096890400 | |||
| ec4b1c8f70 | |||
| 1af904435a | |||
| 7b2f03ba50 | |||
| 005d3e7d64 | |||
| 12f8638223 | |||
| 137b0754d6 | |||
| 7d1e9cfd72 | |||
| d01a39e0c6 | |||
| 73bd0137e3 | |||
| e3f9e8c842 | |||
| 7a38726b26 | |||
| a475f72d50 | |||
| 36cadf39e9 | |||
| a559ef9f90 | |||
| b45f6e0393 | |||
| b99ff6c981 | |||
| 81021f5821 | |||
| 29724b352b | |||
| be83302b14 | |||
| 83d7ea9ef1 | |||
| 95024442de | |||
| 69f54b5f22 | |||
| 3404f95b2e | |||
| e56738481b | |||
| cb59dc353b | |||
| d1b75eac08 | |||
| 1f7651d0e3 | |||
| 8fabd4e4ed | |||
| 564d92bed7 | |||
| d73dd47e7b | |||
| 95f103ccc2 | |||
| c21b232a33 | |||
| 0ace2fdae7 | |||
| dfb2a31f26 | |||
| 5da3541584 | |||
| ef86d2f1f1 | |||
| be98425956 | |||
| 61d1f87611 | |||
| 598d66ac7f | |||
| a10a6d1af8 | |||
| 7640908781 | |||
| b101e25e7a | |||
| 319f257ee5 | |||
| 14d40697b2 | |||
| 6e6b1beffd | |||
| e22de5c9a0 | |||
| 1eea4dab33 | |||
| 83518de981 | |||
| 6d87174cc1 | |||
| 2da18d4500 | |||
| 9af9c3fe77 | |||
| 9cedf5da4c | |||
| d50396ce68 | |||
| f7d4080472 | |||
| e24ff1b92b | |||
| 0c05cbc9db | |||
| 906d675dca | |||
| 860ef73fab | |||
| ec6158792a | |||
| f1b3105202 | |||
| 3ebb213916 | |||
| 97536086c0 | |||
| 0853f8da85 | |||
| 32d36d66c9 | |||
| 2aef75a70a | |||
| fc21d10192 | |||
| c6bd94532d | |||
| a65ca205de | |||
| c8e08b8ef8 | |||
| 683d793460 | |||
| d430efa7ab | |||
| c828c6ede3 | |||
| 3e1120612b | |||
| 8d06d39a62 | |||
| f64d4c9272 | |||
| b2f6620d80 | |||
| 812d38878c | |||
| da7fea47c6 | |||
| 71ddaf04b9 | |||
| 6e1316cb95 | |||
| f2442b25f6 | |||
| bfb8912518 | |||
| 300d3ff09b | |||
| e6337b8f14 | |||
| 39d45ba4b0 | |||
| 2be785ace3 | |||
| 5e2d991fab | |||
| 536cb4caf1 | |||
| 27745ea141 | |||
| 5289c55740 | |||
| 791773fc8a | |||
| 3179b2794b | |||
| 1da27e6c2b | |||
| bea6031de1 | |||
| 3608242b25 | |||
| 5602701645 | |||
| a909b7904e | |||
| 6e0af6827e | |||
| 51ff861e44 | |||
| aa092ab3f3 | |||
| aaaace8dd3 | |||
| 1b1abce7da | |||
| fbc10be381 | |||
| 61f2647b62 | |||
| a5bea7fc59 | |||
| b9be5c2561 | |||
| 97556de447 | |||
| ea805a7af8 | |||
| c9d55a4a5e | |||
| d404970c74 | |||
| 66bf667100 | |||
| c5d1439422 | |||
| 5e9f4559b6 | |||
| 4bbb0441a6 | |||
| 4cf1d7d9a4 | |||
| a6a3ddca75 | |||
| 27cfa85d3a | |||
| a9e1e7b634 | |||
| 9f5f920c81 | |||
| 09c19512d9 | |||
| 212b86d8f6 | |||
| a86b831735 | |||
| f9a0d91299 | |||
| d5bde0d8df | |||
| cc5ca0b5fe | |||
| 0cb9cc6840 | |||
| d38d7b1ff4 | |||
| 2d87f933d5 | |||
| a734a0cff7 | |||
| d0ace55d03 | |||
| 3fda0308ac | |||
| d796b2afc1 | |||
| f95cfc2ee0 | |||
| 82c2560822 | |||
| f467b8cb6c | |||
| aea1a03453 | |||
| 1568e5f19c | |||
| 8dff47db78 | |||
| 987e48733a | |||
| ac5142443a | |||
| 44360d83aa | |||
| 021cb817d4 | |||
| f4f91fba78 | |||
| dec5e8ad6c | |||
| 4321c8d24e | |||
| 6cb3fcf9ad | |||
| e5878554bd | |||
| 44c8c4b5b8 |
@@ -44,6 +44,7 @@ src\Umbraco.Web.UI\[Mm]acro[Ss]cripts\*
|
||||
src\Umbraco.Web.UI\[Xx]slt\*
|
||||
src\Umbraco.Web.UI\[Ii]mages\*
|
||||
src\Umbraco.Web.UI\[Ss]cripts\*
|
||||
src\Umbraco.Web.UI\Web.*.config.transformed
|
||||
|
||||
umbraco\presentation\umbraco\plugins\uComponents\uComponentsInstaller.ascx
|
||||
umbraco\presentation\packages\uComponents\MultiNodePicker\CustomTreeService.asmx
|
||||
|
||||
@@ -24,3 +24,8 @@ f6da531fbb4c251ff61d314e2a7effb13c71e74a Release-4.10.0
|
||||
54cde33b809dcb3a1f7e7ae0d5375f6dd0d89c8d Release-4.11.2.2
|
||||
ff3bb24ea0c915878396a6ae27f1ff164e8ac150 Release-6.0.0-beta
|
||||
56015ac26f5ab60e3c61b1d09075297b660afa07 Release-6.0.0-RC
|
||||
1719fbd857f28b376639ac2aa0abada0ef2e7560 Release-6.0.0
|
||||
e02f5aebb87e3f07d27376647756caa9762931d8 Release-4.11.4
|
||||
14338b0ab1738fbd8987677ecdb9a73d79fc229d release-4.11.6
|
||||
b247b35d821144849f551e02da8ba719f91d5fb0 Release-6.0.2
|
||||
aed55cba29009ad3db48880a7cfb66407ce9805f release-6.0.3
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
@ECHO OFF
|
||||
SET release=6.0.0
|
||||
SET release=6.0.4
|
||||
SET comment=
|
||||
SET version=%release%
|
||||
|
||||
|
||||
+48
-1
@@ -1,3 +1,4 @@
|
||||
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<!--
|
||||
@@ -13,7 +14,45 @@
|
||||
|
||||
<Import Project="..\tools\UmbracoMSBuildTasks\Umbraco.MSBuild.Tasks.Targets" />
|
||||
<Import Project="..\tools\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
|
||||
|
||||
<UsingTask TaskName="GenerateHash" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
|
||||
<OutputFile ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Using Namespace="System.IO" />
|
||||
<Using Namespace="System.Linq" />
|
||||
<Using Namespace="System.Security.Cryptography" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
foreach (var item in InputFiles)
|
||||
{
|
||||
string path = item.ItemSpec;
|
||||
|
||||
using (FileStream stream = new FileStream(path, FileMode.Open))
|
||||
{
|
||||
using (var cryptoProvider = new SHA1CryptoServiceProvider())
|
||||
{
|
||||
|
||||
var fileHash = cryptoProvider.ComputeHash(stream);
|
||||
|
||||
using (TextWriter w = new StreamWriter(OutputFile, false))
|
||||
{
|
||||
w.WriteLine(string.Join("", fileHash.Select(b => b.ToString("x2"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
|
||||
<!--
|
||||
****************************************************
|
||||
VARIABLES
|
||||
@@ -71,10 +110,18 @@
|
||||
*****************************************************
|
||||
-->
|
||||
|
||||
<Target Name="Build" DependsOnTargets="ZipWebPiApp">
|
||||
<Target Name="Build" DependsOnTargets="GenerateWebPiHash">
|
||||
<Message Text="Build finished" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GenerateWebPiHash" DependsOnTargets="ZipWebPiApp">
|
||||
<ItemGroup>
|
||||
<WebPiFile Include="$(BuildZipFileNameWebPi)" />
|
||||
</ItemGroup>
|
||||
<Message Text="Calculating hash for $(BuildZipFileNameWebPi)" />
|
||||
<GenerateHash InputFiles="@(WebPiFile)" OutputFile="webpihash.txt" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CleanUp" DependsOnTargets="ZipWebPiApp">
|
||||
<Message Text="Deleting $(BuildFolder)" Importance="high" />
|
||||
<RemoveDir Directories="$(BuildFolder)" />
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<language>en-US</language>
|
||||
<tags>umbraco</tags>
|
||||
<dependencies>
|
||||
<dependency id="UmbracoCms.Core" version="$version$" />
|
||||
<dependency id="UmbracoCms.Core" version="[$version$]" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
||||
@@ -21,29 +21,44 @@ echo ^<?xml version="1.0" encoding="utf-8"?^>^<packages^>^</packages^> >..\src\U
|
||||
echo Removing plugin cache files
|
||||
del ..\src\Umbraco.Web.UI\App_Data\TEMP\PluginCache\*.*
|
||||
|
||||
echo Removing cache files and examine index
|
||||
del ..\src\Umbraco.Web.UI\App_Data\TEMP\*.*
|
||||
|
||||
echo Removing log files
|
||||
del ..\src\Umbraco.Web.UI\App_Data\Logs\*.*
|
||||
|
||||
echo Removing packages
|
||||
del ..\src\Umbraco.Web.UI\App_Data\packages\*.*
|
||||
|
||||
echo Removing previews
|
||||
del ..\src\Umbraco.Web.UI\App_Data\preview\*.*
|
||||
|
||||
echo Removing app code files (typically added by starterkits)
|
||||
del ..\src\Umbraco.Web.UI\App_Code\*.*
|
||||
|
||||
echo Removing xslt files
|
||||
del ..\src\Umbraco.Web.UI\Xslt\*.*
|
||||
del ..\src\Umbraco.Web.UI\xslt\*.*
|
||||
|
||||
echo Removing user control files
|
||||
del ..\src\Umbraco.Web.UI\UserControls\*.*
|
||||
|
||||
echo Removing masterpage files
|
||||
del ..\src\Umbraco.Web.UI\masterpages\*.*
|
||||
|
||||
echo Removing view files
|
||||
del ..\src\Umbraco.Web.UI\Views\*.*
|
||||
|
||||
echo Removing razor files
|
||||
del ..\src\Umbraco.Web.UI\MacroScripts\*.*
|
||||
del ..\src\Umbraco.Web.UI\macroScripts\*.*
|
||||
|
||||
echo Removing media files
|
||||
del ..\src\Umbraco.Web.UI\Media\*.*
|
||||
del ..\src\Umbraco.Web.UI\media\*.*
|
||||
|
||||
echo Removing script files
|
||||
del ..\src\Umbraco.Web.UI\Scripts\*.*
|
||||
del ..\src\Umbraco.Web.UI\scripts\*.*
|
||||
|
||||
echo Removing css files
|
||||
del ..\src\Umbraco.Web.UI\Css\*.*
|
||||
del ..\src\Umbraco.Web.UI\css\*.*
|
||||
|
||||
echo "Umbraco install reverted to clean install"
|
||||
pause
|
||||
@@ -64,29 +79,44 @@ echo ^<?xml version="1.0" encoding="utf-8"?^>^<packages^>^</packages^> >..\src\U
|
||||
echo Removing plugin cache files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\TEMP\PluginCache\*.*) DO DEL %%A
|
||||
|
||||
echo Removing cache files and examine index
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\TEMP\*.*) DO DEL %%A
|
||||
|
||||
echo Removing log files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\Logs\*.*) DO DEL %%A
|
||||
|
||||
echo Removing packages
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\packages\*.*) DO DEL %%A
|
||||
|
||||
echo Removing previews
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\preview\*.*) DO DEL %%A
|
||||
|
||||
echo Removing app code files (typically added by starterkits)
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Code\*.*) DO DEL %%A
|
||||
|
||||
echo Removing xslt files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\Xslt\*.*) DO DEL %%A
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\xslt\*.*) DO DEL %%A
|
||||
|
||||
echo Removing masterpage files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\masterpages\*.*) DO DEL %%A
|
||||
|
||||
echo Removing user control files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\UserControls\*.*) DO DEL %%A
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\usercontrols\*.*) DO DEL %%A
|
||||
|
||||
echo Removing view files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\Views\*.*) DO DEL %%A
|
||||
|
||||
echo Removing razor files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\MacroScripts\*.*) DO DEL %%A
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\macroScripts\*.*) DO DEL %%A
|
||||
|
||||
echo Removing media files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\Media\*.*) DO DEL %%A
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\media\*.*) DO DEL %%A
|
||||
|
||||
echo Removing script files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\Scripts\*.*) DO DEL %%A
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\scripts\*.*) DO DEL %%A
|
||||
|
||||
echo Removing css files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\Css\*.*) DO DEL %%A
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\css\*.*) DO DEL %%A
|
||||
|
||||
echo "Umbraco install reverted to clean install"
|
||||
pause
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
@ECHO OFF
|
||||
|
||||
:choice
|
||||
set /P c=WARNING! Are you sure you want to continue, this will remove all package files, view files, sqlce database, etc... Press 'Y' to auto-remove all files/folders, 'N' to cancel or 'C' to prompt for each folder removal?
|
||||
if /I "%c%" EQU "C" goto :prompt
|
||||
if /I "%c%" EQU "Y" goto :auto
|
||||
if /I "%c%" EQU "N" goto :exit
|
||||
goto :choice
|
||||
|
||||
|
||||
:prompt
|
||||
|
||||
echo Current folder: %CD%
|
||||
|
||||
echo Regenerating SQL CE database
|
||||
SET buildfolder=%CD%
|
||||
CD ..\tools\RegenerateUmbracoSQLCEDatabase\
|
||||
RegenerateUmbracoSQLCEDatabase.exe %CD%\..\..\src\Umbraco.Web.UI
|
||||
CD %buildfolder%
|
||||
|
||||
echo Removing bin files
|
||||
del ..\src\Umbraco.Web.UI\bin\*.*
|
||||
|
||||
echo Building solution
|
||||
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ..\src\umbraco.sln /t:Clean,Build
|
||||
|
||||
echo Resetting installedPackages.config
|
||||
echo ^<?xml version="1.0" encoding="utf-8"?^>^<packages^>^</packages^> >..\src\Umbraco.Web.UI\App_Data\packages\installed\installedPackages.config
|
||||
|
||||
echo Removing plugin cache files
|
||||
del ..\src\Umbraco.Web.UI\App_Data\TEMP\PluginCache\*.*
|
||||
|
||||
echo Removing cache files and examine index
|
||||
del ..\src\Umbraco.Web.UI\App_Data\TEMP\*.*
|
||||
|
||||
echo Removing log files
|
||||
del ..\src\Umbraco.Web.UI\App_Data\Logs\*.*
|
||||
|
||||
echo Removing packages
|
||||
del ..\src\Umbraco.Web.UI\App_Data\packages\*.*
|
||||
|
||||
echo Removing previews
|
||||
del ..\src\Umbraco.Web.UI\App_Data\preview\*.*
|
||||
|
||||
echo Removing app code files (typically added by starterkits)
|
||||
del ..\src\Umbraco.Web.UI\App_Code\*.*
|
||||
|
||||
echo Removing xslt files
|
||||
del ..\src\Umbraco.Web.UI\xslt\*.*
|
||||
|
||||
echo Removing user control files
|
||||
del ..\src\Umbraco.Web.UI\UserControls\*.*
|
||||
|
||||
echo Removing masterpage files
|
||||
del ..\src\Umbraco.Web.UI\masterpages\*.*
|
||||
|
||||
echo Removing view files
|
||||
del ..\src\Umbraco.Web.UI\Views\*.*
|
||||
|
||||
echo Removing razor files
|
||||
del ..\src\Umbraco.Web.UI\macroScripts\*.*
|
||||
|
||||
echo Removing media files
|
||||
del ..\src\Umbraco.Web.UI\media\*.*
|
||||
|
||||
echo Removing script files
|
||||
del ..\src\Umbraco.Web.UI\scripts\*.*
|
||||
|
||||
echo Removing css files
|
||||
del ..\src\Umbraco.Web.UI\css\*.*
|
||||
|
||||
echo "Umbraco install reverted to clean install"
|
||||
pause
|
||||
exit
|
||||
|
||||
|
||||
|
||||
:auto
|
||||
|
||||
echo Current folder: %CD%
|
||||
|
||||
echo Regenerating SQL CE database
|
||||
SET buildfolder=%CD%
|
||||
CD ..\tools\RegenerateUmbracoSQLCEDatabase\
|
||||
RegenerateUmbracoSQLCEDatabase.exe %CD%\..\..\src\Umbraco.Web.UI
|
||||
CD %buildfolder%
|
||||
|
||||
echo Removing bin files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\bin\*.*) DO DEL %%A
|
||||
|
||||
echo Building solution
|
||||
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ..\src\umbraco.sln /t:Clean,Build
|
||||
|
||||
echo Resetting installedPackages.config
|
||||
echo ^<?xml version="1.0" encoding="utf-8"?^>^<packages^>^</packages^> >..\src\Umbraco.Web.UI\App_Data\packages\installed\installedPackages.config
|
||||
|
||||
echo Removing plugin cache files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\TEMP\PluginCache\*.*) DO DEL %%A
|
||||
|
||||
echo Removing cache files and examine index
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\TEMP\*.*) DO DEL %%A
|
||||
|
||||
echo Removing log files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\Logs\*.*) DO DEL %%A
|
||||
|
||||
echo Removing packages
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\packages\*.*) DO DEL %%A
|
||||
|
||||
echo Removing previews
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Data\preview\*.*) DO DEL %%A
|
||||
|
||||
echo Removing app code files (typically added by starterkits)
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\App_Code\*.*) DO DEL %%A
|
||||
|
||||
echo Removing xslt files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\xslt\*.*) DO DEL %%A
|
||||
|
||||
echo Removing masterpage files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\masterpages\*.*) DO DEL %%A
|
||||
|
||||
echo Removing user control files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\usercontrols\*.*) DO DEL %%A
|
||||
|
||||
echo Removing view files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\Views\*.*) DO DEL %%A
|
||||
|
||||
echo Removing razor files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\macroScripts\*.*) DO DEL %%A
|
||||
|
||||
echo Removing media files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\media\*.*) DO DEL %%A
|
||||
|
||||
echo Removing script files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\scripts\*.*) DO DEL %%A
|
||||
|
||||
echo Removing css files
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\css\*.*) DO DEL %%A
|
||||
|
||||
echo Removing Courier files
|
||||
del ..\src\Umbraco.Web.UI\config\courier.config
|
||||
del ..\src\Umbraco.Web.UI\umbraco\images\tray\courier.jpg
|
||||
rmdir "..\src\Umbraco.Web.UI\umbraco\plugins\courier\" /S /Q
|
||||
|
||||
echo Removing Contour files
|
||||
del ..\src\Umbraco.Web.UI\umbraco\images\tray\contour.png
|
||||
FOR %%A IN (..\src\Umbraco.Web.UI\umbraco\images\umbraco\icon_*.*) DO DEL %%A
|
||||
rmdir "..\src\Umbraco.Web.UI\umbraco\plugins\umbracoContour\" /S /Q
|
||||
del ..\src\Umbraco.Web.UI\umbraco\xslt\templates\UmbracoContour*.* /S /Q
|
||||
rmdir "..\src\Umbraco.Web.UI\usercontrols\umbracoContour\" /S /Q
|
||||
|
||||
echo Start with a clean web.config
|
||||
copy ..\src\Umbraco.Web.UI\web.Template.config ..\src\Umbraco.Web.UI\web.config /Y
|
||||
|
||||
echo "Umbraco install reverted to clean install"
|
||||
pause
|
||||
exit
|
||||
|
||||
|
||||
|
||||
:exit
|
||||
exit
|
||||
Binary file not shown.
@@ -1,24 +0,0 @@
|
||||
Hi! Thanks for grabbing the Umbraco sourcecode.
|
||||
|
||||
===========================================
|
||||
NOTE - DEFAULT BRANCH EMPTY - December 2010
|
||||
===========================================
|
||||
|
||||
|
||||
- With the help of CodePlex we have migrated much of our previous changesets (as of Dec 13th 2010) from TFS to Mercurial.
|
||||
|
||||
- However, not everything could be migrated to our new branching workflow. So for each nominal group of 4.x changes, we've created named branches. For upcoming 5.x changesets, we'll adhere to our new workflow which we'll describe on the Wiki for contributors.
|
||||
|
||||
- FOR THE MOMENT, the 'default' branch is empty - pending the addition of the 5.0 changesets
|
||||
|
||||
- To switch to the codebase on which you want to work, 'hg update' to the named branch (e.g. "4.6.0") or tag (e.g. "Release-4.5.2") and browse or work from that point.
|
||||
|
||||
|
||||
Thanks to Matt Hawley at CodePlex for his help in our migration!
|
||||
|
||||
Cheers,
|
||||
The Umbraco Team
|
||||
|
||||
http://umbraco.org
|
||||
http://our.umbraco.org
|
||||
http://umbraco.codeplex.com
|
||||
@@ -1,82 +0,0 @@
|
||||
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f36\fswiss\fcharset0\fprq2{\*\panose 020b0604030504040204}Tahoma;}
|
||||
{\f39\froman\fcharset238\fprq2 Times New Roman CE;}{\f40\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f42\froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\froman\fcharset162\fprq2 Times New Roman Tur;}
|
||||
{\f44\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f46\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}
|
||||
{\f399\fswiss\fcharset238\fprq2 Tahoma CE;}{\f400\fswiss\fcharset204\fprq2 Tahoma Cyr;}{\f402\fswiss\fcharset161\fprq2 Tahoma Greek;}{\f403\fswiss\fcharset162\fprq2 Tahoma Tur;}{\f404\fswiss\fcharset177\fprq2 Tahoma (Hebrew);}
|
||||
{\f405\fswiss\fcharset178\fprq2 Tahoma (Arabic);}{\f406\fswiss\fcharset186\fprq2 Tahoma Baltic;}{\f407\fswiss\fcharset163\fprq2 Tahoma (Vietnamese);}{\f408\fswiss\fcharset222\fprq2 Tahoma (Thai);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;
|
||||
\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;
|
||||
\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive
|
||||
\ssemihidden Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
|
||||
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
|
||||
\f36\fs16\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext15 \ssemihidden \styrsid668380 Balloon Text;}}{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\listtable{\list\listtemplateid130696116{\listlevel\levelnfc0\levelnfcn0\leveljc0
|
||||
\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\jclisttab\tx720\lin720 }{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0
|
||||
{\leveltext\'02\'01.;}{\levelnumbers\'01;}\fi-360\li1440\jclisttab\tx1440\lin1440 }{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'02.;}{\levelnumbers\'01;}\fi-360\li2160
|
||||
\jclisttab\tx2160\lin2160 }{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'03.;}{\levelnumbers\'01;}\fi-360\li2880\jclisttab\tx2880\lin2880 }{\listlevel\levelnfc0\levelnfcn0\leveljc0
|
||||
\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'04.;}{\levelnumbers\'01;}\fi-360\li3600\jclisttab\tx3600\lin3600 }{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0
|
||||
{\leveltext\'02\'05.;}{\levelnumbers\'01;}\fi-360\li4320\jclisttab\tx4320\lin4320 }{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'06.;}{\levelnumbers\'01;}\fi-360\li5040
|
||||
\jclisttab\tx5040\lin5040 }{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'07.;}{\levelnumbers\'01;}\fi-360\li5760\jclisttab\tx5760\lin5760 }{\listlevel\levelnfc0\levelnfcn0\leveljc0
|
||||
\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'08.;}{\levelnumbers\'01;}\fi-360\li6480\jclisttab\tx6480\lin6480 }{\listname ;}\listid723138990}}{\*\listoverridetable{\listoverride\listid723138990\listoverridecount0\ls1}}
|
||||
{\*\pgptbl {\pgp\ipgp2\itap0\li0\ri0\sb0\sa0}{\pgp\ipgp0\itap0\li0\ri0\sb0\sa0}{\pgp\ipgp4\itap0\li0\ri0\sb0\sa0}{\pgp\ipgp0\itap0\li0\ri0\sb0\sa0}{\pgp\ipgp0\itap0\li0\ri0\sb0\sa0}}{\*\rsidtbl \rsid288726\rsid668380\rsid1077358\rsid1250157\rsid1778664
|
||||
\rsid2232581\rsid3018318\rsid3766585\rsid4417501\rsid4531485\rsid4807452\rsid5341002\rsid7018004\rsid7880391\rsid10749719\rsid12150908\rsid12939982\rsid13596669\rsid15149892\rsid15551579\rsid16128754\rsid16674677}{\*\generator Microsoft Word 11.0.6359;}
|
||||
{\info{\title Shared Source License for Software included in Workspaces}{\author suev}{\operator Martin Maly}{\creatim\yr2005\mo3\dy22\hr10\min45}{\revtim\yr2005\mo3\dy22\hr15\min54}{\printim\yr2002\mo9\dy20\hr15\min39}{\version3}{\edmins1}{\nofpages1}
|
||||
{\nofwords672}{\nofchars3837}{\*\company Microsoft}{\nofcharsws4501}{\vern24703}}\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984
|
||||
\dghshow1\dgvshow1\jexpand\viewkind5\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
|
||||
\asianbrkrule\nojkernpunct\rsidroot15149892 \fet0\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3
|
||||
\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}
|
||||
{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain
|
||||
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b\fs28\insrsid1250157\charrsid1250157 Shared Source License for }{\b\fs28\insrsid16674677 IronPython}{
|
||||
\b\fs28\insrsid1250157
|
||||
\par }{\b\fs28\insrsid5341002
|
||||
\par }{\b\insrsid5341002\charrsid5341002 This license governs use of the accompanying software}{\b\insrsid5341002 (\'93Software\'94)}{\b\insrsid5341002\charrsid5341002 , and your use of the }{\b\insrsid5341002 S}{\b\insrsid5341002\charrsid5341002
|
||||
oftware constitutes acceptance of this license.
|
||||
\par }{\insrsid1250157\charrsid5341002
|
||||
\par }{\b\insrsid1250157\charrsid1250157 You }{\b\insrsid5341002 may}{\b\insrsid1250157\charrsid1250157 use }{\b\insrsid5341002 the}{\b\insrsid1250157\charrsid1250157 Software for any }{\b\insrsid1250157 commercial or }{\b\insrsid1250157\charrsid1250157
|
||||
noncommercial purpose, including distributing derivative}{\b\insrsid4417501 work}{\b\insrsid1250157\charrsid1250157 s}{\b\insrsid1250157 .
|
||||
\par }{\insrsid1250157
|
||||
\par }\pard \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid1250157 {\insrsid1250157\charrsid1250157 In return, we simply require that you agree:
|
||||
\par {\listtext\pard\plain\insrsid1250157\charrsid1250157 \hich\af0\dbch\af0\loch\f0 1.\tab}}\pard \ql \fi-360\li720\ri0\widctlpar\jclisttab\tx720\aspalpha\aspnum\faauto\ls1\adjustright\rin0\lin720\itap0\pararsid1250157 {\insrsid1250157\charrsid1250157
|
||||
Not to remove any copyright}{\insrsid5341002 or other}{\insrsid1250157\charrsid1250157 notices from the Software.
|
||||
\par {\listtext\pard\plain\insrsid1250157\charrsid1250157 \hich\af0\dbch\af0\loch\f0 2.\tab}That if you distribute the Software in source code form you do so only under this }{\insrsid5341002 l}{\insrsid1250157\charrsid1250157
|
||||
icense (i.e. you must include a complete copy of this }{\insrsid5341002 l}{\insrsid1250157\charrsid1250157 icense with your distribution), and if you distribute the Software solely in object form you only do so under a license that complies with this }{
|
||||
\insrsid5341002 l}{\insrsid1250157\charrsid1250157 icense.
|
||||
\par {\listtext\pard\plain\b\insrsid1250157\charrsid1250157 \hich\af0\dbch\af0\loch\f0 3.\tab}}{\b\insrsid1250157\charrsid1250157
|
||||
That the Software comes "as is", with no warranties. None whatsoever. This means no express, implied or statutory warranty, including without limitation, warranties of merchantability or fitness for a particular purpose or any warranty of }{
|
||||
\b\insrsid5341002 title or }{\b\insrsid1250157\charrsid1250157 non}{\b\insrsid5341002 -}{\b\insrsid1250157\charrsid1250157 infringement. Also, you must pass this disclaimer on whenever you distribute the Software}{\b\insrsid5341002 or derivative works}{
|
||||
\b\insrsid1250157\charrsid1250157 .}{\insrsid1250157\charrsid1250157
|
||||
\par {\listtext\pard\plain\b\insrsid1250157\charrsid1250157 \hich\af0\dbch\af0\loch\f0 4.\tab}}{\b\insrsid1250157\charrsid1250157 That neither Microsoft nor }{\b\insrsid1250157 any contributor to the Software}{\b\insrsid1250157\charrsid1250157
|
||||
will be liable for any of those types of damages known as}{\b\insrsid5341002 }{\b\insrsid1250157\charrsid1250157 indirect, special, consequential, or incidental related to the Software or this }{\b\insrsid5341002 l}{\b\insrsid1250157\charrsid1250157
|
||||
icense, to the maximum extent the law permits, no matter what legal theory it\rquote s based on. Also, you must pass this limitation of liability on whenever you distribute the Software}{\b\insrsid5341002 or derivative works}{
|
||||
\b\insrsid1250157\charrsid1250157 .}{\insrsid1250157\charrsid1250157
|
||||
\par {\listtext\pard\plain\insrsid1250157\charrsid1250157 \hich\af0\dbch\af0\loch\f0 5.\tab}That if you sue anyone over patents that you think may apply to the Software for a person's use of the Software, your license to the Software ends automatically.
|
||||
|
||||
\par {\listtext\pard\plain\insrsid1250157 \hich\af0\dbch\af0\loch\f0 6.\tab}}{\insrsid1250157 That the patent rights, if any, }{\insrsid288726 granted in this license}{\insrsid1250157\charrsid1250157 only apply to the Software, not to any derivative}{
|
||||
\insrsid4417501 work}{\insrsid1250157\charrsid1250157 s you make.}{\insrsid3018318
|
||||
\par {\listtext\pard\plain\insrsid3018318\charrsid3018318 \hich\af0\dbch\af0\loch\f0 7.\tab}}{\insrsid3018318\charrsid3018318 That if you are an agency of the U.S. Government, (i) Software provided pursuant to a solicitation issued on or after Dece
|
||||
mber 1, 1995, is provided with the commercial license rights set forth in this license, and (ii) Software provided pursuant to a solicitation issued prior to December 1, 1995, is provided with \'93Restricted Rights\'94
|
||||
as set forth in FAR, 48 C.F.R. 52.227-14 (June 1987) or DFAR, 48 C.F.R. 252.227-7013 (Oct 1988), as applicable.}{\insrsid1250157
|
||||
\par {\listtext\pard\plain\insrsid1250157 \hich\af0\dbch\af0\loch\f0 8.\tab}That your rights under this License end automatically if you breach it in any way.
|
||||
\par {\listtext\pard\plain\insrsid5341002 \hich\af0\dbch\af0\loch\f0 9.\tab}}{\insrsid5341002 That all rights not expressly granted to you in this license are reserved.
|
||||
\par }\pard \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid1778664 {\insrsid1778664
|
||||
\par }{\insrsid12150908 Read below}{\insrsid1778664 for answers to frequently asked questions about this license.
|
||||
\par }{\insrsid12150908
|
||||
\par }\pard \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid12150908 {\b\insrsid12150908\charrsid12150908 Q: Is this license OSI compliant?
|
||||
\par }{\insrsid12150908
|
||||
A: This license has not been submitted to OSI, but it allows developers to take full advantage of a dynamic language on the CLR and to have the freedom to distribute their works for the benefit of the community at large. The license is half of a
|
||||
page long and very straight forward. We believe it stands up to what developers demand of an "open" license.
|
||||
\par
|
||||
\par }{\b\insrsid12150908\charrsid12150908 Q: What copyright rights does the license grant me?
|
||||
\par }{\insrsid12150908 A: The license grants you a copyright license to make unlimited copies of the Software in sour
|
||||
ce or object code form, as well as to create Derivative Works (as that term is defined under US copyright law). This means that in addition to making unlimited copies of the Software, you have a copyright license to modify the Software and to use all or p
|
||||
art of the Software to create a Derivative Work.
|
||||
\par
|
||||
\par }{\b\insrsid12150908\charrsid12150908 Q: What patent rights does the license grant me?
|
||||
\par }{\insrsid12150908 A: This license grants you a patent license to use and distribute the Software under any Microsoft patent claims that read on the Software itself. In other wo
|
||||
rds, if you create a modified version of the Software, you still retain the patent license to use and distribute the original portions of the Software under the specific Microsoft patent claims that read on the Software, but you do not have a patent licen
|
||||
s
|
||||
e as to the new functionality you may have added by modifying the Software. This result is typical of many common open source licenses, including the Common Public License (CPL) and the Mozilla Public License (MPL). In addition, this license grants no rig
|
||||
h
|
||||
ts to any Microsoft patents that read on other components or files not included in the Software. This means that no patent license is granted to use or distribute any other software or technology that may be needed to use the Software or was created from
|
||||
t
|
||||
he Software (for example, any compiled output of the Software, the combination of the Software with other hardware or other software, or any additional enabling technologies that may be necessary to make or use the Software or any final product that inclu
|
||||
des the Software).}{\insrsid12150908
|
||||
\par }{\insrsid12150908\charrsid1250157
|
||||
\par }}
|
||||
+30
-6
@@ -1,9 +1,33 @@
|
||||
!! Umbraco - the simple, flexible and friendly ASP.NET CMS
|
||||
Umbraco - the simple, flexible and friendly ASP.NET CMS
|
||||
=======================================================
|
||||
For the first time on the Microsoft platform a free user and developer friendly cms that makes it quick and easy to create websites - or a breeze to build complex web applications. umbraco got award-winning integration capabilities and supports your ASP.NET User and Custom Controls out of the box. It's a developers dream and your users will love it too. Used by more than 57.000 active websites including Heinz.com, Peugeot.com, NAIAS.com and Microsofts documentinteropinitiative.org website you can be sure that the technology is proven, stable and scales.
|
||||
[url:More info at http://umbraco.org|http://umbraco.org]
|
||||
|
||||
!! Forums
|
||||
We have a forum running on [url:http://our.umbraco.org]. The discussions area on CodePlex will be for discussions on developing the core, and not on Umbraco-implementations or extensions in general. For those topics, please use [url:http://our.umbraco.org].
|
||||
More info at http://umbraco.com
|
||||
|
||||
!! Submitting Issues
|
||||
Another way you can contribute to Umbraco is by providing issue reports, for information on how to submit an issue report refer to our [url:online guide|http://our.umbraco.org/wiki/how-tos/submitting-bug-reports].
|
||||
Exploring the repository
|
||||
========================
|
||||
Most contributors will work on their own fork and should pick the branch in which they need their fix. For more information see:
|
||||
http://our.umbraco.org/contribute/guidelines-for-core-contribution
|
||||
|
||||
Exploring the source
|
||||
====================
|
||||
The Umbraco source code is never required for you to start building sites. If you are not using the source code for debugging purposes or to contribute to the source then please download the binaries listed at http://umbraco.codeplex.com
|
||||
|
||||
With that said, the Umbraco solution can be opened in Visual Studio 2010 with SP1 installed or Visual Studio 2012.
|
||||
|
||||
Contributing
|
||||
============
|
||||
Umbraco is Open Source which means you can contribute to make it great!
|
||||
Read all about it at http://our.umbraco.org/contribute
|
||||
|
||||
Forums
|
||||
======
|
||||
We have a forum running on http://our.umbraco.org for friendly community support.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
Our documentation section provides help on installing and using Umbraco including API reference documentation: http://our.umbraco.org/documentation
|
||||
|
||||
Submitting Issues
|
||||
=================
|
||||
Another way you can contribute to Umbraco is by providing issue reports, for information on how to submit an issue report refer to our online guide at http://our.umbraco.org/contribute/report-an-issue-or-request-a-feature
|
||||
@@ -50,35 +50,90 @@ namespace SqlCE4Umbraco
|
||||
/// </summary>
|
||||
internal void ClearDatabase()
|
||||
{
|
||||
// drop constraints before tables to avoid exceptions
|
||||
// looping on try/catching exceptions was not really nice
|
||||
|
||||
// http://stackoverflow.com/questions/536350/drop-all-the-tables-stored-procedures-triggers-constriants-and-all-the-depend
|
||||
|
||||
var localConnection = new SqlCeConnection(ConnectionString);
|
||||
if (System.IO.File.Exists(ReplaceDataDirectory(localConnection.Database)))
|
||||
{
|
||||
var tables = new List<string>();
|
||||
using (var reader = ExecuteReader("select table_name from information_schema.tables where TABLE_TYPE <> 'VIEW'"))
|
||||
List<string> tables;
|
||||
|
||||
// drop foreign keys
|
||||
// SQL may need "where constraint_catalog=DB_NAME() and ..."
|
||||
tables = new List<string>();
|
||||
using (var reader = ExecuteReader("select table_name from information_schema.table_constraints where constraint_type = 'FOREIGN KEY' order by table_name"))
|
||||
{
|
||||
while (reader.Read())
|
||||
while (reader.Read()) tables.Add(reader.GetString("table_name").Trim());
|
||||
}
|
||||
|
||||
foreach (var table in tables)
|
||||
{
|
||||
var constraints = new List<string>();
|
||||
using (var reader = ExecuteReader("select constraint_name from information_schema.table_constraints where constraint_type = 'FOREIGN KEY' and table_name = '" + table + "' order by constraint_name"))
|
||||
{
|
||||
tables.Add(reader.GetString("TABLE_NAME"));
|
||||
while (reader.Read()) constraints.Add(reader.GetString("constraint_name").Trim());
|
||||
}
|
||||
foreach (var constraint in constraints)
|
||||
{
|
||||
// SQL may need "[dbo].[table]"
|
||||
ExecuteNonQuery("alter table [" + table + "] drop constraint [" + constraint + "]");
|
||||
}
|
||||
}
|
||||
|
||||
while(tables.Any())
|
||||
// drop primary keys
|
||||
// SQL may need "where constraint_catalog=DB_NAME() and ..."
|
||||
tables = new List<string>();
|
||||
using (var reader = ExecuteReader("select table_name from information_schema.table_constraints where constraint_type = 'PRIMARY KEY' order by table_name"))
|
||||
{
|
||||
for (var i = 0; i < tables.Count; i++)
|
||||
{
|
||||
var dropTable = "DROP TABLE " + tables[i];
|
||||
while (reader.Read()) tables.Add(reader.GetString("table_name").Trim());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ExecuteNonQuery(dropTable);
|
||||
tables.Remove(tables[i]);
|
||||
}
|
||||
catch (SqlHelperException ex)
|
||||
{
|
||||
//this will occur because there is no cascade option, so we just wanna try the next one
|
||||
}
|
||||
foreach (var table in tables)
|
||||
{
|
||||
var constraints = new List<string>();
|
||||
using (var reader = ExecuteReader("select constraint_name from information_schema.table_constraints where constraint_type = 'PRIMARY KEY' and table_name = '" + table + "' order by constraint_name"))
|
||||
{
|
||||
while (reader.Read()) constraints.Add(reader.GetString("constraint_name").Trim());
|
||||
}
|
||||
foreach (var constraint in constraints)
|
||||
{
|
||||
// SQL may need "[dbo].[table]"
|
||||
ExecuteNonQuery("alter table [" + table + "] drop constraint [" + constraint + "]");
|
||||
}
|
||||
}
|
||||
|
||||
// drop tables
|
||||
tables = new List<string>();
|
||||
using (var reader = ExecuteReader("select table_name from information_schema.tables where table_type <> 'VIEW' order by table_name"))
|
||||
{
|
||||
while (reader.Read()) tables.Add(reader.GetString("table_name").Trim());
|
||||
}
|
||||
|
||||
foreach (var table in tables)
|
||||
{
|
||||
ExecuteNonQuery("drop table [" + table + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drops all foreign keys on a table.
|
||||
/// </summary>
|
||||
/// <param name="table">The name of the table.</param>
|
||||
/// <remarks>To be used in unit tests.</remarks>
|
||||
internal void DropForeignKeys(string table)
|
||||
{
|
||||
var constraints = new List<string>();
|
||||
using (var reader = ExecuteReader("select constraint_name from information_schema.table_constraints where constraint_type = 'FOREIGN KEY' and table_name = '" + table + "' order by constraint_name"))
|
||||
{
|
||||
while (reader.Read()) constraints.Add(reader.GetString("constraint_name").Trim());
|
||||
}
|
||||
foreach (var constraint in constraints)
|
||||
{
|
||||
// SQL may need "[dbo].[table]"
|
||||
ExecuteNonQuery("alter table [" + table + "] drop constraint [" + constraint + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +149,9 @@ namespace SqlCE4Umbraco
|
||||
var dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory") as string;
|
||||
if (!string.IsNullOrEmpty(dataDirectory))
|
||||
{
|
||||
path = path.Replace("|DataDirectory|", dataDirectory + System.IO.Path.DirectorySeparatorChar);
|
||||
path = path.Contains(@"|\")
|
||||
? path.Replace("|DataDirectory|", dataDirectory)
|
||||
: path.Replace("|DataDirectory|", dataDirectory + System.IO.Path.DirectorySeparatorChar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace Umbraco.Core
|
||||
/// <summary>
|
||||
/// A resolver to return all IAction objects
|
||||
/// </summary>
|
||||
internal sealed class ActionsResolver : ManyObjectsResolverBase<ActionsResolver, IAction>
|
||||
internal sealed class ActionsResolver : LazyManyObjectsResolverBase<ActionsResolver, IAction>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="packageActions"></param>
|
||||
internal ActionsResolver(IEnumerable<Type> packageActions)
|
||||
internal ActionsResolver(Func<IEnumerable<Type>> packageActions)
|
||||
: base(packageActions)
|
||||
{
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace Umbraco.Core
|
||||
}
|
||||
|
||||
protected override IEnumerable<IAction> CreateInstances()
|
||||
{
|
||||
{
|
||||
var actions = new List<IAction>();
|
||||
var foundIActions = PluginManager.Current.ResolveActions();
|
||||
var foundIActions = InstanceTypes;
|
||||
foreach (var type in foundIActions)
|
||||
{
|
||||
IAction typeInstance;
|
||||
|
||||
@@ -100,6 +100,18 @@ namespace Umbraco.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The original/first url that the web application executes
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must
|
||||
/// exist on a global context because the keep alive service doesn't run in a web context.
|
||||
/// we are NOT going to put a lock on this because locking will slow down the application and we don't really care
|
||||
/// if two threads write to this at the exact same time during first page hit.
|
||||
/// see: http://issues.umbraco.org/issue/U4-2059
|
||||
/// </remarks>
|
||||
internal string OriginalRequestUrl { get; set; }
|
||||
|
||||
private bool Configured
|
||||
{
|
||||
get
|
||||
@@ -140,7 +152,6 @@ namespace Umbraco.Core
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void AssertIsReady()
|
||||
{
|
||||
if (!this.IsReady)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Core
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="refreshers"></param>
|
||||
internal CacheRefreshersResolver(IEnumerable<Type> refreshers)
|
||||
internal CacheRefreshersResolver(Func<IEnumerable<Type>> refreshers)
|
||||
: base(refreshers)
|
||||
{
|
||||
|
||||
|
||||
@@ -28,24 +28,49 @@ namespace Umbraco.Core.Configuration
|
||||
#region Private static fields
|
||||
|
||||
private static Version _version;
|
||||
private static string _reservedUrlsCache;
|
||||
private static readonly object Locker = new object();
|
||||
//make this volatile so that we can ensure thread safety with a double check lock
|
||||
private static volatile string _reservedUrlsCache;
|
||||
private static string _reservedPathsCache;
|
||||
private static StartsWithContainer _reservedList = new StartsWithContainer();
|
||||
private static string _reservedPaths;
|
||||
private static string _reservedUrls;
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
private const string StaticReservedPaths = "~/app_plugins/,~/install/,";
|
||||
private const string StaticReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,";
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// used for unit tests
|
||||
/// </summary>
|
||||
internal static void ResetCache()
|
||||
{
|
||||
_reservedUrlsCache = null;
|
||||
_reservedPaths = null;
|
||||
_reservedUrls = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reserved urls from web.config.
|
||||
/// </summary>
|
||||
/// <value>The reserved urls.</value>
|
||||
public static string ReservedUrls
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
|
||||
: string.Empty;
|
||||
{
|
||||
if (_reservedUrls == null)
|
||||
{
|
||||
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
|
||||
: string.Empty;
|
||||
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
_reservedUrls = StaticReservedUrls + urls;
|
||||
}
|
||||
return _reservedUrls;
|
||||
}
|
||||
internal set { _reservedUrls = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,10 +81,25 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
|
||||
: string.Empty;
|
||||
if (_reservedPaths == null)
|
||||
{
|
||||
var reservedPaths = StaticReservedPaths;
|
||||
//always add the umbraco path to the list
|
||||
if (ConfigurationManager.AppSettings.ContainsKey("umbracoPath")
|
||||
&& !ConfigurationManager.AppSettings["umbracoPath"].IsNullOrWhiteSpace())
|
||||
{
|
||||
reservedPaths += ConfigurationManager.AppSettings["umbracoPath"].EnsureEndsWith(',');
|
||||
}
|
||||
|
||||
var allPaths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
|
||||
: string.Empty;
|
||||
|
||||
_reservedPaths = reservedPaths + allPaths;
|
||||
}
|
||||
return _reservedPaths;
|
||||
}
|
||||
internal set { _reservedPaths = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -114,6 +154,9 @@ namespace Umbraco.Core.Configuration
|
||||
/// This will return the MVC area that we will route all custom routes through like surface controllers, etc...
|
||||
/// We will use the 'Path' (default ~/umbraco) to create it but since it cannot contain '/' and people may specify a path of ~/asdf/asdf/admin
|
||||
/// we will convert the '/' to '-' and use that as the path. its a bit lame but will work.
|
||||
///
|
||||
/// We also make sure that the virtual directory (SystemDirectories.Root) is stripped off first, otherwise we'd end up with something
|
||||
/// like "MyVirtualDirectory-Umbraco" instead of just "Umbraco".
|
||||
/// </remarks>
|
||||
internal static string UmbracoMvcArea
|
||||
{
|
||||
@@ -123,7 +166,7 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
throw new InvalidOperationException("Cannot create an MVC Area path without the umbracoPath specified");
|
||||
}
|
||||
return Path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim();
|
||||
return Path.TrimStart(SystemDirectories.Root).TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +244,7 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Saves a setting into the configuration file.
|
||||
/// </summary>
|
||||
@@ -622,38 +666,42 @@ namespace Umbraco.Core.Configuration
|
||||
/// </returns>
|
||||
public static bool IsReservedPathOrUrl(string url)
|
||||
{
|
||||
// check if GlobalSettings.ReservedPaths and GlobalSettings.ReservedUrls are unchanged
|
||||
if (!object.ReferenceEquals(_reservedPathsCache, GlobalSettings.ReservedPaths)
|
||||
|| !object.ReferenceEquals(_reservedUrlsCache, GlobalSettings.ReservedUrls))
|
||||
if (_reservedUrlsCache == null)
|
||||
{
|
||||
// store references to strings to determine changes
|
||||
_reservedPathsCache = GlobalSettings.ReservedPaths;
|
||||
_reservedUrlsCache = GlobalSettings.ReservedUrls;
|
||||
|
||||
string _root = SystemDirectories.Root.Trim().ToLower();
|
||||
|
||||
// add URLs and paths to a new list
|
||||
StartsWithContainer _newReservedList = new StartsWithContainer();
|
||||
foreach (string reservedUrl in _reservedUrlsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
lock (Locker)
|
||||
{
|
||||
//resolves the url to support tilde chars
|
||||
string reservedUrlTrimmed = IOHelper.ResolveUrl(reservedUrl).Trim().ToLower();
|
||||
if (reservedUrlTrimmed.Length > 0)
|
||||
_newReservedList.Add(reservedUrlTrimmed);
|
||||
if (_reservedUrlsCache == null)
|
||||
{
|
||||
// store references to strings to determine changes
|
||||
_reservedPathsCache = GlobalSettings.ReservedPaths;
|
||||
_reservedUrlsCache = GlobalSettings.ReservedUrls;
|
||||
|
||||
string _root = SystemDirectories.Root.Trim().ToLower();
|
||||
|
||||
// add URLs and paths to a new list
|
||||
StartsWithContainer _newReservedList = new StartsWithContainer();
|
||||
foreach (string reservedUrl in _reservedUrlsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
//resolves the url to support tilde chars
|
||||
string reservedUrlTrimmed = IOHelper.ResolveUrl(reservedUrl).Trim().ToLower();
|
||||
if (reservedUrlTrimmed.Length > 0)
|
||||
_newReservedList.Add(reservedUrlTrimmed);
|
||||
}
|
||||
|
||||
foreach (string reservedPath in _reservedPathsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
bool trimEnd = !reservedPath.EndsWith("/");
|
||||
//resolves the url to support tilde chars
|
||||
string reservedPathTrimmed = IOHelper.ResolveUrl(reservedPath).Trim().ToLower();
|
||||
|
||||
if (reservedPathTrimmed.Length > 0)
|
||||
_newReservedList.Add(reservedPathTrimmed + (reservedPathTrimmed.EndsWith("/") ? "" : "/"));
|
||||
}
|
||||
|
||||
// use the new list from now on
|
||||
_reservedList = _newReservedList;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string reservedPath in _reservedPathsCache.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
bool trimEnd = !reservedPath.EndsWith("/");
|
||||
//resolves the url to support tilde chars
|
||||
string reservedPathTrimmed = IOHelper.ResolveUrl(reservedPath).Trim().ToLower();
|
||||
|
||||
if (reservedPathTrimmed.Length > 0)
|
||||
_newReservedList.Add(reservedPathTrimmed + (reservedPathTrimmed.EndsWith("/") ? "" : "/"));
|
||||
}
|
||||
|
||||
// use the new list from now on
|
||||
_reservedList = _newReservedList;
|
||||
}
|
||||
|
||||
//The url should be cleaned up before checking:
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.InfrastructureSettings
|
||||
{
|
||||
public class Infrastructure : ConfigurationSection
|
||||
{
|
||||
private const string InfrastructureSectionName = "umbraco/infrastructure";
|
||||
|
||||
public static Infrastructure Instance
|
||||
{
|
||||
get { return (Infrastructure) ConfigurationManager.GetSection(InfrastructureSectionName); }
|
||||
}
|
||||
|
||||
#region RepositoriesSection Property
|
||||
|
||||
internal const string RepositoriesPropertyName = "repositories";
|
||||
|
||||
[ConfigurationProperty(RepositoriesPropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
|
||||
public Repositories Repositories
|
||||
{
|
||||
get { return ((Repositories)base[RepositoriesPropertyName]); }
|
||||
set { base[RepositoriesPropertyName] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PublishingStrategy Property
|
||||
|
||||
internal const string PublishingStrategyPropertyName = "publishingStrategy";
|
||||
|
||||
[ConfigurationProperty(PublishingStrategyPropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
|
||||
public PublishingProvider PublishingStrategy
|
||||
{
|
||||
get { return ((PublishingProvider)base[PublishingStrategyPropertyName]); }
|
||||
set { base[PublishingStrategyPropertyName] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class Repositories : ConfigurationElement
|
||||
{
|
||||
[ConfigurationProperty("", IsDefaultCollection = true, IsRequired = true)]
|
||||
public RepositoryElementCollection Repository
|
||||
{
|
||||
get { return ((RepositoryElementCollection)(base[""])); }
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationCollection(typeof(Repository), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate, AddItemName = RepositoryPropertyName)]
|
||||
public class RepositoryElementCollection : ConfigurationElementCollection
|
||||
{
|
||||
internal const string RepositoryPropertyName = "repository";
|
||||
|
||||
public override ConfigurationElementCollectionType CollectionType
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfigurationElementCollectionType.BasicMapAlternate;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string ElementName
|
||||
{
|
||||
get
|
||||
{
|
||||
return RepositoryPropertyName;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool IsElementName(string elementName)
|
||||
{
|
||||
return elementName == RepositoryPropertyName;
|
||||
}
|
||||
|
||||
protected override object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
return ((Repository)element).InterfaceShortTypeName;
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new Repository();
|
||||
}
|
||||
|
||||
#region Indexer
|
||||
|
||||
public Repository this[int index]
|
||||
{
|
||||
get { return (Repository)base.BaseGet(index); }
|
||||
}
|
||||
|
||||
public Repository this[string interfaceShortTypeName]
|
||||
{
|
||||
get { return (Repository)base.BaseGet(interfaceShortTypeName); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add
|
||||
|
||||
public void Add(Repository repository)
|
||||
{
|
||||
BaseAdd(repository);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Remove
|
||||
|
||||
public void Remove(Repository repository)
|
||||
{
|
||||
BaseRemove(repository);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetItem
|
||||
|
||||
public Repository GetItemAt(int index)
|
||||
{
|
||||
return (Repository)BaseGet(index);
|
||||
}
|
||||
|
||||
public Repository GetItemByKey(string interfaceShortTypeName)
|
||||
{
|
||||
return (Repository)BaseGet(interfaceShortTypeName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public bool ContainsKey(string interfaceShortName)
|
||||
{
|
||||
bool result = false;
|
||||
object[] keys = this.BaseGetAllKeys();
|
||||
foreach (object key in keys)
|
||||
{
|
||||
if ((string)key == interfaceShortName)
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class Repository : ConfigurationElement
|
||||
{
|
||||
internal const string InterfaceShortTypeNamePropertyName = "interfaceShortTypeName";
|
||||
|
||||
[ConfigurationPropertyAttribute(InterfaceShortTypeNamePropertyName, IsRequired = true, IsKey = true, IsDefaultCollection = false)]
|
||||
public string InterfaceShortTypeName
|
||||
{
|
||||
get { return (string) base[InterfaceShortTypeNamePropertyName]; }
|
||||
set { base[InterfaceShortTypeNamePropertyName] = value; }
|
||||
}
|
||||
|
||||
internal const string RepositoryFullTypeNamePropertyName = "repositoryFullTypeName";
|
||||
|
||||
[ConfigurationPropertyAttribute(RepositoryFullTypeNamePropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
|
||||
public string RepositoryFullTypeName
|
||||
{
|
||||
get { return (string)base[RepositoryFullTypeNamePropertyName]; }
|
||||
set { base[RepositoryFullTypeNamePropertyName] = value; }
|
||||
}
|
||||
|
||||
internal const string CacheProviderFullTypeNamePropertyName = "cacheProviderFullTypeName";
|
||||
|
||||
[ConfigurationPropertyAttribute(CacheProviderFullTypeNamePropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
|
||||
public string CacheProviderFullTypeName
|
||||
{
|
||||
get { return (string)base[CacheProviderFullTypeNamePropertyName]; }
|
||||
set { base[CacheProviderFullTypeNamePropertyName] = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public class PublishingProvider : ConfigurationElement
|
||||
{
|
||||
internal const string TypePropertyName = "type";
|
||||
|
||||
[ConfigurationPropertyAttribute(TypePropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
|
||||
public string Type
|
||||
{
|
||||
get { return (string)base[TypePropertyName]; }
|
||||
set { base[TypePropertyName] = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,31 @@ namespace Umbraco.Core.Configuration
|
||||
/// </summary>
|
||||
internal class UmbracoSettings
|
||||
{
|
||||
/// <summary>
|
||||
private static bool GetKeyValue(string key, bool defaultValue)
|
||||
{
|
||||
bool value;
|
||||
string stringValue = GetKey(key);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(stringValue))
|
||||
return defaultValue;
|
||||
if (bool.TryParse(stringValue, out value))
|
||||
return value;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static int GetKeyValue(string key, int defaultValue)
|
||||
{
|
||||
int value;
|
||||
string stringValue = GetKey(key);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(stringValue))
|
||||
return defaultValue;
|
||||
if (int.TryParse(stringValue, out value))
|
||||
return value;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used in unit testing to reset all config items that were set with property setters (i.e. did not come from config)
|
||||
/// </summary>
|
||||
internal static void ResetSetters()
|
||||
@@ -35,6 +59,7 @@ namespace Umbraco.Core.Configuration
|
||||
_useLegacySchema = null;
|
||||
_useDomainPrefixes = null;
|
||||
_umbracoLibraryCacheDuration = null;
|
||||
_trySkipIisCustomErrors = null;
|
||||
SettingsFilePath = null;
|
||||
}
|
||||
|
||||
@@ -126,11 +151,32 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
EnsureSettingsDocument();
|
||||
|
||||
string attrName = null;
|
||||
var pos = key.IndexOf('@');
|
||||
if (pos > 0)
|
||||
{
|
||||
attrName = key.Substring(pos + 1);
|
||||
key = key.Substring(0, pos - 1);
|
||||
}
|
||||
|
||||
var node = UmbracoSettingsXmlDoc.DocumentElement.SelectSingleNode(key);
|
||||
if (node == null || node.FirstChild == null || node.FirstChild.Value == null)
|
||||
return string.Empty;
|
||||
return node.FirstChild.Value;
|
||||
}
|
||||
if (node == null)
|
||||
return string.Empty;
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
if (node.FirstChild == null || node.FirstChild.Value == null)
|
||||
return string.Empty;
|
||||
return node.FirstChild.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
var attr = node.Attributes[attrName];
|
||||
if (attr == null)
|
||||
return string.Empty;
|
||||
return attr.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the media library will create new directories in the /media directory.
|
||||
@@ -203,6 +249,7 @@ namespace Umbraco.Core.Configuration
|
||||
return value != null ? value.Attributes["assembly"].Value : "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of an external logger that can be used to store log items in 3rd party systems
|
||||
/// </summary>
|
||||
@@ -351,24 +398,13 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_useDomainPrefixes.HasValue)
|
||||
return _useDomainPrefixes.Value;
|
||||
bool result;
|
||||
if (bool.TryParse(GetKey("/settings/requestHandler/useDomainPrefixes"), out result))
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// default: false
|
||||
return _useDomainPrefixes ?? GetKeyValue("/settings/requestHandler/useDomainPrefixes", false);
|
||||
}
|
||||
// for unit tests only
|
||||
internal set
|
||||
{
|
||||
_useDomainPrefixes = value;
|
||||
// for unit tests only
|
||||
_useDomainPrefixes = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,31 +418,14 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GlobalSettings.UseDirectoryUrls)
|
||||
{
|
||||
if (_addTrailingSlash.HasValue)
|
||||
return _addTrailingSlash.Value;
|
||||
bool result;
|
||||
if (bool.TryParse(GetKey("/settings/requestHandler/addTrailingSlash"), out result))
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// default: false
|
||||
return GlobalSettings.UseDirectoryUrls
|
||||
&& (_addTrailingSlash ?? GetKeyValue("/settings/requestHandler/addTrailingSlash", false));
|
||||
}
|
||||
// for unit tests only
|
||||
internal set
|
||||
{
|
||||
_addTrailingSlash = value;
|
||||
// for unit tests only
|
||||
_addTrailingSlash = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,31 +642,46 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_forceSafeAliases.HasValue)
|
||||
return _forceSafeAliases.Value;
|
||||
|
||||
string forceSafeAlias = GetKey("/settings/content/ForceSafeAliases");
|
||||
if (String.IsNullOrEmpty(forceSafeAlias))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
return bool.Parse(forceSafeAlias);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// default: true
|
||||
return _forceSafeAliases ?? GetKeyValue("/settings/content/ForceSafeAliases", true);
|
||||
}
|
||||
internal set
|
||||
{
|
||||
//used for unit testing
|
||||
// used for unit testing
|
||||
_forceSafeAliases = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool? _trySkipIisCustomErrors;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating where to try to skip IIS custom errors.
|
||||
/// </summary>
|
||||
public static bool TrySkipIisCustomErrors
|
||||
{
|
||||
get
|
||||
{
|
||||
// default: false
|
||||
return _trySkipIisCustomErrors ?? GetKeyValue("/settings/web.routing/@trySkipIisCustomErrors", false);
|
||||
}
|
||||
internal set
|
||||
{
|
||||
// used for unit testing
|
||||
_trySkipIisCustomErrors = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File types that will not be allowed to be uploaded via the content/media upload control
|
||||
/// </summary>
|
||||
public static IEnumerable<string> DisallowedUploadFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
var val = GetKey("/settings/content/disallowedUploadFiles");
|
||||
return val.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the allowed image file types.
|
||||
@@ -677,26 +711,14 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_umbracoLibraryCacheDuration.HasValue)
|
||||
return _umbracoLibraryCacheDuration.Value;
|
||||
|
||||
string libraryCacheDuration = GetKey("/settings/content/UmbracoLibraryCacheDuration");
|
||||
if (String.IsNullOrEmpty(libraryCacheDuration))
|
||||
return 1800;
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
return int.Parse(libraryCacheDuration);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 1800;
|
||||
}
|
||||
}
|
||||
|
||||
// default: 1800
|
||||
return _umbracoLibraryCacheDuration ?? GetKeyValue("/settings/content/UmbracoLibraryCacheDuration", 1800);
|
||||
}
|
||||
internal set { _umbracoLibraryCacheDuration = value; }
|
||||
internal set
|
||||
{
|
||||
// for unit tests only
|
||||
_umbracoLibraryCacheDuration = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1052,27 +1074,12 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_useLegacySchema.HasValue)
|
||||
return _useLegacySchema.Value;
|
||||
|
||||
string value = GetKey("/settings/content/UseLegacyXmlSchema");
|
||||
bool result;
|
||||
if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result))
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//default. TODO: When we change this to a real config section we won't have to worry about parse errors
|
||||
// and should handle defaults with unit tests properly.
|
||||
return false;
|
||||
}
|
||||
// default: true
|
||||
return _useLegacySchema ?? GetKeyValue("/settings/content/UseLegacyXmlSchema", false);
|
||||
}
|
||||
internal set
|
||||
{
|
||||
//used for unit testing
|
||||
// used for unit testing
|
||||
_useLegacySchema = value;
|
||||
}
|
||||
}
|
||||
@@ -1221,6 +1228,75 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
private static MacroErrorBehaviour? _macroErrorBehaviour;
|
||||
|
||||
/// <summary>
|
||||
/// This configuration setting defines how to handle macro errors:
|
||||
/// - Inline - Show error within macro as text (default and current Umbraco 'normal' behavior)
|
||||
/// - Silent - Suppress error and hide macro
|
||||
/// - Throw - Throw an exception and invoke the global error handler (if one is defined, if not you'll get a YSOD)
|
||||
/// </summary>
|
||||
/// <value>MacroErrorBehaviour enum defining how to handle macro errors.</value>
|
||||
public static MacroErrorBehaviour MacroErrorBehaviour
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_macroErrorBehaviour == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var behaviour = MacroErrorBehaviour.Inline;
|
||||
var value = GetKey("/settings/content/MacroErrors");
|
||||
if (value != null)
|
||||
{
|
||||
Enum<MacroErrorBehaviour>.TryParse(value, true, out behaviour);
|
||||
}
|
||||
_macroErrorBehaviour = behaviour;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<UmbracoSettings>("Could not load /settings/content/MacroErrors from umbracosettings.config", ex);
|
||||
_macroErrorBehaviour = MacroErrorBehaviour.Inline;
|
||||
}
|
||||
}
|
||||
return _macroErrorBehaviour.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private static IconPickerBehaviour? _iconPickerBehaviour;
|
||||
|
||||
/// <summary>
|
||||
/// This configuration setting defines how to show icons in the document type editor.
|
||||
/// - ShowDuplicates - Show duplicates in files and sprites. (default and current Umbraco 'normal' behaviour)
|
||||
/// - HideSpriteDuplicates - Show files on disk and hide duplicates from the sprite
|
||||
/// - HideFileDuplicates - Show files in the sprite and hide duplicates on disk
|
||||
/// </summary>
|
||||
/// <value>MacroErrorBehaviour enum defining how to show icons in the document type editor.</value>
|
||||
public static IconPickerBehaviour IconPickerBehaviour
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_iconPickerBehaviour == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var behaviour = IconPickerBehaviour.ShowDuplicates;
|
||||
var value = GetKey("/settings/content/DocumentTypeIconList");
|
||||
if (value != null)
|
||||
{
|
||||
Enum<IconPickerBehaviour>.TryParse(value, true, out behaviour);
|
||||
}
|
||||
_iconPickerBehaviour = behaviour;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<UmbracoSettings>("Could not load /settings/content/DocumentTypeIconList from umbracosettings.config", ex);
|
||||
_iconPickerBehaviour = IconPickerBehaviour.ShowDuplicates;
|
||||
}
|
||||
}
|
||||
return _iconPickerBehaviour.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration regarding webservices
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class UmbracoVersion
|
||||
{
|
||||
private static readonly Version Version = new Version("6.0.0");
|
||||
private static readonly Version Version = new Version("6.0.4");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current version of Umbraco.
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
@@ -9,6 +7,8 @@ using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
|
||||
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixZeroOne;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Publishing;
|
||||
@@ -60,27 +60,36 @@ namespace Umbraco.Core
|
||||
new PetaPocoUnitOfWorkProvider(dbFactory),
|
||||
new FileUnitOfWorkProvider(),
|
||||
new PublishingStrategy());
|
||||
|
||||
//create the ApplicationContext
|
||||
ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext);
|
||||
|
||||
//initialize the DatabaseContext
|
||||
dbContext.Initialize();
|
||||
CreateApplicationContext(dbContext, serviceContext);
|
||||
|
||||
InitializeApplicationEventsResolver();
|
||||
|
||||
InitializeResolvers();
|
||||
|
||||
|
||||
//initialize the DatabaseContext
|
||||
dbContext.Initialize();
|
||||
|
||||
//now we need to call the initialize methods
|
||||
ApplicationEventsResolver.Current.ApplicationEventHandlers
|
||||
.ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext));
|
||||
|
||||
|
||||
_isInitialized = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and assigns the application context singleton
|
||||
/// </summary>
|
||||
/// <param name="dbContext"></param>
|
||||
/// <param name="serviceContext"></param>
|
||||
protected virtual void CreateApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
|
||||
{
|
||||
//create the ApplicationContext
|
||||
ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Special method to initialize the ApplicationEventsResolver and any modifications required for it such
|
||||
/// as adding custom types to the resolver.
|
||||
@@ -110,15 +119,15 @@ namespace Umbraco.Core
|
||||
if (_isStarted)
|
||||
throw new InvalidOperationException("The boot manager has already been initialized");
|
||||
|
||||
if (afterStartup != null)
|
||||
{
|
||||
afterStartup(ApplicationContext.Current);
|
||||
}
|
||||
|
||||
//call OnApplicationStarting of each application events handler
|
||||
ApplicationEventsResolver.Current.ApplicationEventHandlers
|
||||
.ForEach(x => x.OnApplicationStarting(UmbracoApplication, ApplicationContext));
|
||||
|
||||
if (afterStartup != null)
|
||||
{
|
||||
afterStartup(ApplicationContext.Current);
|
||||
}
|
||||
|
||||
_isStarted = true;
|
||||
|
||||
return this;
|
||||
@@ -134,21 +143,23 @@ namespace Umbraco.Core
|
||||
if (_isComplete)
|
||||
throw new InvalidOperationException("The boot manager has already been completed");
|
||||
|
||||
//freeze resolution to not allow Resolvers to be modified
|
||||
Resolution.Freeze();
|
||||
FreezeResolution();
|
||||
|
||||
//stop the timer and log the output
|
||||
_timer.Dispose();
|
||||
|
||||
if (afterComplete != null)
|
||||
{
|
||||
afterComplete(ApplicationContext.Current);
|
||||
}
|
||||
|
||||
//call OnApplicationStarting of each application events handler
|
||||
ApplicationEventsResolver.Current.ApplicationEventHandlers
|
||||
.ForEach(x => x.OnApplicationStarted(UmbracoApplication, ApplicationContext));
|
||||
|
||||
//Now, startup all of our legacy startup handler
|
||||
ApplicationEventsResolver.Current.InstantiateLegacyStartupHanlders();
|
||||
|
||||
if (afterComplete != null)
|
||||
{
|
||||
afterComplete(ApplicationContext.Current);
|
||||
}
|
||||
|
||||
_isComplete = true;
|
||||
|
||||
// we're ready to serve content!
|
||||
@@ -157,6 +168,14 @@ namespace Umbraco.Core
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Freeze resolution to not allow Resolvers to be modified
|
||||
/// </summary>
|
||||
protected virtual void FreezeResolution()
|
||||
{
|
||||
Resolution.Freeze();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the resolvers
|
||||
/// </summary>
|
||||
@@ -165,20 +184,26 @@ namespace Umbraco.Core
|
||||
RepositoryResolver.Current = new RepositoryResolver(
|
||||
new RepositoryFactory());
|
||||
|
||||
SqlSyntaxProvidersResolver.Current = new SqlSyntaxProvidersResolver(
|
||||
new[] { typeof(MySqlSyntaxProvider), typeof(SqlCeSyntaxProvider), typeof(SqlServerSyntaxProvider) })
|
||||
{
|
||||
CanResolveBeforeFrozen = true
|
||||
};
|
||||
|
||||
CacheRefreshersResolver.Current = new CacheRefreshersResolver(
|
||||
PluginManager.Current.ResolveCacheRefreshers());
|
||||
() => PluginManager.Current.ResolveCacheRefreshers());
|
||||
|
||||
DataTypesResolver.Current = new DataTypesResolver(
|
||||
PluginManager.Current.ResolveDataTypes());
|
||||
() => PluginManager.Current.ResolveDataTypes());
|
||||
|
||||
MacroFieldEditorsResolver.Current = new MacroFieldEditorsResolver(
|
||||
PluginManager.Current.ResolveMacroRenderings());
|
||||
() => PluginManager.Current.ResolveMacroRenderings());
|
||||
|
||||
PackageActionsResolver.Current = new PackageActionsResolver(
|
||||
PluginManager.Current.ResolvePackageActions());
|
||||
() => PluginManager.Current.ResolvePackageActions());
|
||||
|
||||
ActionsResolver.Current = new ActionsResolver(
|
||||
PluginManager.Current.ResolveActions());
|
||||
() => PluginManager.Current.ResolveActions());
|
||||
|
||||
MacroPropertyTypeResolver.Current = new MacroPropertyTypeResolver(
|
||||
PluginManager.Current.ResolveMacroPropertyTypes());
|
||||
@@ -201,7 +226,8 @@ namespace Umbraco.Core
|
||||
typeof (UpdateCmsContentTypeAllowedContentTypeTable),
|
||||
typeof (UpdateCmsContentTypeTable),
|
||||
typeof (UpdateCmsContentVersionTable),
|
||||
typeof (UpdateCmsPropertyTypeGroupTable)
|
||||
typeof (UpdateCmsPropertyTypeGroupTable),
|
||||
typeof (UpdatePropertyTypesAndGroups)
|
||||
});
|
||||
|
||||
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Core
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="dataTypes"></param>
|
||||
internal DataTypesResolver(IEnumerable<Type> dataTypes)
|
||||
internal DataTypesResolver(Func<IEnumerable<Type>> dataTypes)
|
||||
: base(dataTypes)
|
||||
{
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Core
|
||||
public void ConfigureEmbeddedDatabaseConnection()
|
||||
{
|
||||
const string providerName = "System.Data.SqlServerCe.4.0";
|
||||
const string connectionString = "Datasource=|DataDirectory|Umbraco.sdf";
|
||||
const string connectionString = @"Data Source=|DataDirectory|\Umbraco.sdf";
|
||||
|
||||
SaveConnectionString(connectionString, providerName);
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Umbraco.Core
|
||||
}
|
||||
else if (databaseProvider.ToLower().Contains("azure"))
|
||||
{
|
||||
connectionString = string.Format("Server=tcp:{0}.database.windows.net;Database={1};User ID={2}@{0};Password={3}", server, databaseName, user, password);
|
||||
connectionString = BuildAzureConnectionString(server, databaseName, user, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,6 +169,52 @@ namespace Umbraco.Core
|
||||
Initialize(providerName);
|
||||
}
|
||||
|
||||
internal string BuildAzureConnectionString(string server, string databaseName, string user, string password)
|
||||
{
|
||||
if (server.Contains(".") && ServerStartsWithTcp(server) == false)
|
||||
server = string.Format("tcp:{0}", server);
|
||||
|
||||
if (server.Contains(".") == false && ServerStartsWithTcp(server))
|
||||
{
|
||||
string serverName = server.Contains(",")
|
||||
? server.Substring(0, server.IndexOf(",", StringComparison.Ordinal))
|
||||
: server;
|
||||
|
||||
var portAddition = string.Empty;
|
||||
|
||||
if (server.Contains(","))
|
||||
portAddition = server.Substring(server.IndexOf(",", StringComparison.Ordinal));
|
||||
|
||||
server = string.Format("{0}.database.windows.net{1}", serverName, portAddition);
|
||||
}
|
||||
|
||||
if (ServerStartsWithTcp(server) == false)
|
||||
server = string.Format("tcp:{0}.database.windows.net", server);
|
||||
|
||||
if (server.Contains(",") == false)
|
||||
server = string.Format("{0},1433", server);
|
||||
|
||||
if (user.Contains("@") == false)
|
||||
{
|
||||
var userDomain = server;
|
||||
|
||||
if (ServerStartsWithTcp(server))
|
||||
userDomain = userDomain.Substring(userDomain.IndexOf(":", StringComparison.Ordinal) + 1);
|
||||
|
||||
if (userDomain.Contains("."))
|
||||
userDomain = userDomain.Substring(0, userDomain.IndexOf(".", StringComparison.Ordinal));
|
||||
|
||||
user = string.Format("{0}@{1}", user, userDomain);
|
||||
}
|
||||
|
||||
return string.Format("Server={0};Database={1};User ID={2};Password={3}", server, databaseName, user, password);
|
||||
}
|
||||
|
||||
private static bool ServerStartsWithTcp(string server)
|
||||
{
|
||||
return server.ToLower().StartsWith("tcp:".ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the connection string as a proper .net ConnectionString and the legacy AppSettings key/value.
|
||||
/// </summary>
|
||||
@@ -218,7 +264,7 @@ namespace Umbraco.Core
|
||||
|
||||
xml.Save(fileName, SaveOptions.DisableFormatting);
|
||||
|
||||
LogHelper.Info<DatabaseContext>("Configured new ConnectionString: " + connectionString);
|
||||
LogHelper.Info<DatabaseContext>("Configured a new ConnectionString using the '" + providerName + "' provider.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -232,7 +278,8 @@ namespace Umbraco.Core
|
||||
/// </remarks>
|
||||
internal void Initialize()
|
||||
{
|
||||
if (ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName] != null)
|
||||
var databaseSettings = ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName];
|
||||
if (databaseSettings != null && string.IsNullOrWhiteSpace(databaseSettings.ConnectionString) == false && string.IsNullOrWhiteSpace(databaseSettings.ProviderName) == false)
|
||||
{
|
||||
var providerName = "System.Data.SqlClient";
|
||||
if (!string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName].ProviderName))
|
||||
@@ -254,8 +301,7 @@ namespace Umbraco.Core
|
||||
{
|
||||
ConfigureEmbeddedDatabaseConnection();
|
||||
}
|
||||
else if (legacyConnString.ToLowerInvariant().Contains("database.windows.net") &&
|
||||
legacyConnString.ToLowerInvariant().Contains("tcp:"))
|
||||
else if (legacyConnString.ToLowerInvariant().Contains("tcp:"))
|
||||
{
|
||||
//Must be sql azure
|
||||
SaveConnectionString(legacyConnString, "System.Data.SqlClient");
|
||||
@@ -291,21 +337,22 @@ namespace Umbraco.Core
|
||||
|
||||
internal void Initialize(string providerName)
|
||||
{
|
||||
if (providerName.StartsWith("MySql"))
|
||||
{
|
||||
SyntaxConfig.SqlSyntaxProvider = MySqlSyntax.Provider;
|
||||
}
|
||||
else if (providerName.Contains("SqlServerCe"))
|
||||
{
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
}
|
||||
else
|
||||
{
|
||||
SyntaxConfig.SqlSyntaxProvider = SqlServerSyntax.Provider;
|
||||
}
|
||||
|
||||
_providerName = providerName;
|
||||
_configured = true;
|
||||
|
||||
try
|
||||
{
|
||||
SqlSyntaxContext.SqlSyntaxProvider =
|
||||
SqlSyntaxProvidersResolver.Current.GetByProviderNameOrDefault(providerName);
|
||||
|
||||
_configured = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_configured = false;
|
||||
|
||||
LogHelper.Info<DatabaseContext>("Initialization of the DatabaseContext failed with following error: " + e.Message);
|
||||
LogHelper.Info<DatabaseContext>(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
internal DatabaseSchemaResult ValidateDatabaseSchema()
|
||||
@@ -337,16 +384,56 @@ namespace Umbraco.Core
|
||||
|
||||
try
|
||||
{
|
||||
LogHelper.Info<DatabaseContext>("Database configuration status: Started");
|
||||
|
||||
var message = string.Empty;
|
||||
|
||||
var database = new UmbracoDatabase(_connectionString, ProviderName);
|
||||
var supportsCaseInsensitiveQueries = SqlSyntaxContext.SqlSyntaxProvider.SupportsCaseInsensitiveQueries(database);
|
||||
if (supportsCaseInsensitiveQueries == false)
|
||||
{
|
||||
message = "<p> </p><p>The database you're trying to use does not support case insensitive queries. <br />We currently do not support these types of databases.</p>" +
|
||||
"<p>You can fix this by changing the following two settings in your my.ini file in your MySQL installation directory:</p>" +
|
||||
"<pre>lower_case_table_names=1\nlower_case_file_system=1</pre><br />" +
|
||||
"<p>Note: Make sure to check with your hosting provider if they support case insensitive queries as well.</p>" +
|
||||
"<p>For more technical information on case sensitivity in MySQL, have a look at " +
|
||||
"<a href='http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html'>the documentation on the subject</a></p>";
|
||||
|
||||
return new Result { Message = message, Success = false, Percentage = "15" };
|
||||
}
|
||||
else if (supportsCaseInsensitiveQueries == null)
|
||||
{
|
||||
message = "<p> </p><p>Warning! Could not check if your database type supports case insensitive queries. <br />We currently do not support these databases that do not support case insensitive queries.</p>" +
|
||||
"<p>You can check this by looking for the following two settings in your my.ini file in your MySQL installation directory:</p>" +
|
||||
"<pre>lower_case_table_names=1\nlower_case_file_system=1</pre><br />" +
|
||||
"<p>Note: Make sure to check with your hosting provider if they support case insensitive queries as well.</p>" +
|
||||
"<p>For more technical information on case sensitivity in MySQL, have a look at " +
|
||||
"<a href='http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html'>the documentation on the subject</a></p>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.GetType() == typeof(MySqlSyntaxProvider))
|
||||
{
|
||||
message = "<p> </p><p>Congratulations, the database step ran successfully!</p>" +
|
||||
"<p>Note: You're using MySQL and the database instance you're connecting to seems to support case insensitive queries.</p>" +
|
||||
"<p>However, your hosting provider may not support this option. Umbraco does not currently support MySQL installs that do not support case insensitive queries</p>" +
|
||||
"<p>Make sure to check with your hosting provider if they support case insensitive queries as well.</p>" +
|
||||
"<p>They can check this by looking for the following two settings in the my.ini file in their MySQL installation directory:</p>" +
|
||||
"<pre>lower_case_table_names=1\nlower_case_file_system=1</pre><br />" +
|
||||
"<p>For more technical information on case sensitivity in MySQL, have a look at " +
|
||||
"<a href='http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html'>the documentation on the subject</a></p>";
|
||||
}
|
||||
}
|
||||
|
||||
var schemaResult = ValidateDatabaseSchema();
|
||||
var installedVersion = schemaResult.DetermineInstalledVersion();
|
||||
string message;
|
||||
|
||||
|
||||
//If Configuration Status is empty and the determined version is "empty" its a new install - otherwise upgrade the existing
|
||||
if (string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus) && installedVersion.Equals(new Version(0, 0, 0)))
|
||||
{
|
||||
database.CreateDatabaseSchema();
|
||||
message = "Installation completed!";
|
||||
message = message + "<p>Installation completed!</p>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -356,9 +443,11 @@ namespace Umbraco.Core
|
||||
var targetVersion = UmbracoVersion.Current;
|
||||
var runner = new MigrationRunner(configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName);
|
||||
var upgraded = runner.Execute(database, true);
|
||||
message = "Upgrade completed!";
|
||||
message = message + "<p>Upgrade completed!</p>";
|
||||
}
|
||||
|
||||
LogHelper.Info<DatabaseContext>("Database configuration status: " + message);
|
||||
|
||||
return new Result { Message = message, Success = true, Percentage = "100" };
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -374,7 +463,7 @@ namespace Umbraco.Core
|
||||
{
|
||||
Message =
|
||||
"The database configuration failed with the following message: " + ex.Message +
|
||||
"\n Please check log file for addtional information (can be found in '/App_Data/Logs/UmbracoTraceLog.txt')",
|
||||
"\n Please check log file for additional information (can be found in '/App_Data/Logs/UmbracoTraceLog.txt')",
|
||||
Success = false,
|
||||
Percentage = "90"
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Dictionary
|
||||
/// <summary>
|
||||
/// Resolves the current CultureDictionaryFactory
|
||||
/// </summary>
|
||||
internal class CultureDictionaryFactoryResolver : SingleObjectResolverBase<CultureDictionaryFactoryResolver, ICultureDictionaryFactory>
|
||||
internal sealed class CultureDictionaryFactoryResolver : SingleObjectResolverBase<CultureDictionaryFactoryResolver, ICultureDictionaryFactory>
|
||||
{
|
||||
internal CultureDictionaryFactoryResolver(ICultureDictionaryFactory factory)
|
||||
: base(factory)
|
||||
|
||||
@@ -9,35 +9,106 @@ using System.Xml.XPath;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
[TypeConverter(typeof(DynamicXmlConverter))]
|
||||
public class DynamicXml : DynamicObject, IEnumerable<DynamicXml>, IEnumerable<XElement>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the XElement used to create the DynamicXml structure
|
||||
/// </summary>
|
||||
public XElement BaseElement { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the raw XElement used to create the DynamicXml structure if one was specified otherwise returns the
|
||||
/// same value as BaseElement.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is purely used for when an instance of DynamicXml is created with the overload that supports
|
||||
/// passing in both a raw xml version and a dash-stripped xml version. Otherwise this value is exactly the
|
||||
/// same as BaseElement.
|
||||
/// </remarks>
|
||||
public XElement RawXmlElement { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="baseElement"></param>
|
||||
public DynamicXml(XElement baseElement)
|
||||
{
|
||||
this.BaseElement = baseElement;
|
||||
if (baseElement == null) return;
|
||||
|
||||
//same
|
||||
RawXmlElement = baseElement;
|
||||
BaseElement = baseElement;
|
||||
}
|
||||
public DynamicXml(string xml)
|
||||
|
||||
/// <summary>
|
||||
/// When this constructor is used the BaseElement becomes equivalent to the strippedXml structure
|
||||
/// </summary>
|
||||
/// <param name="strippedXml"></param>
|
||||
/// <param name="rawXml"></param>
|
||||
internal DynamicXml(XElement strippedXml, XElement rawXml)
|
||||
{
|
||||
var baseElement = XElement.Parse(xml);
|
||||
this.BaseElement = baseElement;
|
||||
if (rawXml == null) return;
|
||||
if (strippedXml == null) return;
|
||||
|
||||
RawXmlElement = rawXml;
|
||||
BaseElement = strippedXml;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When this constructor is used the BaseElement becomes equivalent to the strippedXml structure
|
||||
/// </summary>
|
||||
/// <param name="strippedXml"></param>
|
||||
/// <param name="rawXml"></param>
|
||||
internal DynamicXml(string strippedXml, string rawXml)
|
||||
{
|
||||
if (rawXml == null) return;
|
||||
if (strippedXml == null) return;
|
||||
|
||||
RawXmlElement = XElement.Parse(rawXml);
|
||||
BaseElement = XElement.Parse(strippedXml);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="xml"></param>
|
||||
public DynamicXml(string xml)
|
||||
{
|
||||
if (xml.IsNullOrWhiteSpace()) return;
|
||||
|
||||
var baseElement = XElement.Parse(xml);
|
||||
|
||||
//same
|
||||
RawXmlElement = baseElement;
|
||||
BaseElement = baseElement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="xpni"></param>
|
||||
public DynamicXml(XPathNodeIterator xpni)
|
||||
{
|
||||
if (xpni != null)
|
||||
{
|
||||
if (xpni.Current != null)
|
||||
{
|
||||
var xml = xpni.Current.OuterXml;
|
||||
var baseElement = XElement.Parse(xml);
|
||||
this.BaseElement = baseElement;
|
||||
}
|
||||
}
|
||||
if (xpni == null) return;
|
||||
if (xpni.Current == null) return;
|
||||
|
||||
//TODO: OuterXml is really bad for performance! Should actually use the XPathNodeIterator api
|
||||
var xml = xpni.Current.OuterXml;
|
||||
var baseElement = XElement.Parse(xml);
|
||||
|
||||
//same
|
||||
RawXmlElement = baseElement;
|
||||
BaseElement = baseElement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the InnertText based on the BaseElement object
|
||||
/// </summary>
|
||||
public string InnerText
|
||||
{
|
||||
get
|
||||
@@ -45,17 +116,34 @@ namespace Umbraco.Core.Dynamics
|
||||
return BaseElement.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string representation of the BaseElement object
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToXml()
|
||||
{
|
||||
return BaseElement.ToString(SaveOptions.DisableFormatting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string representation of the RawXmlElement object
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToRawXml()
|
||||
{
|
||||
return RawXmlElement.ToString(SaveOptions.DisableFormatting);
|
||||
}
|
||||
|
||||
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
|
||||
{
|
||||
int index = 0;
|
||||
if (indexes.Length > 0)
|
||||
{
|
||||
index = (int)indexes[0];
|
||||
result = new DynamicXml(this.BaseElement.Elements().ToList()[index]);
|
||||
result = new DynamicXml(
|
||||
RawXmlElement.Elements().ElementAt(index),
|
||||
BaseElement.Elements().ElementAt(index));
|
||||
return true;
|
||||
}
|
||||
return base.TryGetIndex(binder, indexes, out result);
|
||||
@@ -64,12 +152,12 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
if (args.Length == 0 && binder.Name == "ToXml")
|
||||
{
|
||||
result = this.BaseElement.ToString();
|
||||
result = BaseElement.ToString();
|
||||
return true;
|
||||
}
|
||||
if (args.Length == 1 && binder.Name == "XPath")
|
||||
{
|
||||
var elements = this.BaseElement.XPathSelectElements(args[0].ToString());
|
||||
var elements = BaseElement.XPathSelectElements(args[0].ToString());
|
||||
HandleIEnumerableXElement(elements, out result);
|
||||
return true; //anyway
|
||||
}
|
||||
@@ -102,7 +190,9 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
else if (attempt.Result.ObjectResult is IEnumerable<DynamicXml>)
|
||||
{
|
||||
result = ((IEnumerable<DynamicXml>)attempt.Result.ObjectResult).Select(x => new DynamicXml(x.BaseElement));
|
||||
result = ((IEnumerable<DynamicXml>) attempt.Result.ObjectResult).Select(x => new DynamicXml(
|
||||
x.RawXmlElement,
|
||||
x.BaseElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,55 +213,102 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
||||
{
|
||||
if (BaseElement == null || binder == null)
|
||||
if (RawXmlElement == null || binder == null)
|
||||
{
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
//Go ahead and try to fetch all of the elements matching the member name, and wrap them
|
||||
var elements = BaseElement.Elements(binder.Name);
|
||||
if (!elements.Any() && BaseElement.Name == "root" && BaseElement.Elements().Count() == 1)
|
||||
{
|
||||
//no elements matched, lets try first child
|
||||
elements = BaseElement.Elements().ElementAt(0).Elements(binder.Name);
|
||||
}
|
||||
if (HandleIEnumerableXElement(elements, out result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//Ok, so no elements matched, so lets try attributes
|
||||
IEnumerable<string> attributes = BaseElement.Attributes(binder.Name).Select(attr => attr.Value);
|
||||
int count = attributes.Count();
|
||||
|
||||
if (count > 0)
|
||||
//Check if the name matches a node based on the BaseElement (which if the correct ctor is used, will be dash stripped)
|
||||
var elementByNameAttempt = CheckNodeNameMatch(binder.Name, BaseElement);
|
||||
if (elementByNameAttempt.Success)
|
||||
{
|
||||
if (HandleIEnumerableXElement(elementByNameAttempt.Result, out result))
|
||||
{
|
||||
if (count > 1)
|
||||
result = attributes; //more than one attribute matched, lets return the collection
|
||||
else
|
||||
result = attributes.FirstOrDefault(); //only one attribute matched, lets just return it
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true; // return true because we matched
|
||||
//Check if the name matches a node based on the BaseElement (which if the correct ctor is used, will be dash stripped)
|
||||
var attributeByNameAttempt = CheckAttributeNameMatch(binder.Name, BaseElement);
|
||||
if (attributeByNameAttempt.Success)
|
||||
{
|
||||
if (attributeByNameAttempt.Result.Count() > 1)
|
||||
{
|
||||
//more than one attribute matched, lets return the collection
|
||||
result = attributeByNameAttempt.Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
//no attributes matched, lets try first child
|
||||
if (BaseElement.Name == "root" && BaseElement.Elements().Count() == 1)
|
||||
{
|
||||
attributes = BaseElement.Elements().ElementAt(0).Attributes(binder.Name).Select(attr => attr.Value);
|
||||
count = attributes.Count();
|
||||
if (count > 1)
|
||||
result = attributes; //more than one attribute matched, lets return the collection
|
||||
else
|
||||
result = attributes.FirstOrDefault(); //only one attribute matched, lets just return it
|
||||
//only one attribute matched, lets just return it
|
||||
result = attributeByNameAttempt.Result.FirstOrDefault();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return true; // return true because we matched
|
||||
}
|
||||
return base.TryGetMember(binder, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the 'name' matches any attributes of xmlElement
|
||||
/// </summary>
|
||||
/// <param name="name">The name to match</param>
|
||||
/// <param name="xmlElement">The xml element to check against</param>
|
||||
/// <returns></returns>
|
||||
private static Attempt<IEnumerable<string>> CheckAttributeNameMatch(string name, XElement xmlElement)
|
||||
{
|
||||
var attributes = xmlElement.Attributes(name).Select(attr => attr.Value).ToArray();
|
||||
if (attributes.Any())
|
||||
{
|
||||
return new Attempt<IEnumerable<string>>(true, attributes);
|
||||
}
|
||||
|
||||
if (!attributes.Any() && xmlElement.Name == "root" && xmlElement.Elements().Count() == 1)
|
||||
{
|
||||
//no elements matched and this node is called 'root' and only has one child... lets see if it matches.
|
||||
var childElements = xmlElement.Elements().ElementAt(0).Attributes(name).Select(attr => attr.Value).ToArray();
|
||||
if (childElements.Any())
|
||||
{
|
||||
//we've found a match by the first child of an element called 'root' (strange, but sure)
|
||||
return new Attempt<IEnumerable<string>>(true, childElements);
|
||||
}
|
||||
}
|
||||
|
||||
//no deal
|
||||
return Attempt<IEnumerable<string>>.False;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the 'name' matches any elements of xmlElement
|
||||
/// </summary>
|
||||
/// <param name="name">The name to match</param>
|
||||
/// <param name="xmlElement">The xml element to check against</param>
|
||||
/// <returns></returns>
|
||||
private Attempt<IEnumerable<XElement>> CheckNodeNameMatch(string name, XElement xmlElement)
|
||||
{
|
||||
//Go ahead and try to fetch all of the elements matching the member name, and wrap them
|
||||
var elements = xmlElement.Elements(name).ToArray();
|
||||
|
||||
//Check if we've got any matches, if so then return true
|
||||
if (elements.Any())
|
||||
{
|
||||
return new Attempt<IEnumerable<XElement>>(true, elements);
|
||||
}
|
||||
|
||||
if (!elements.Any() && xmlElement.Name == "root" && xmlElement.Elements().Count() == 1)
|
||||
{
|
||||
//no elements matched and this node is called 'root' and only has one child... lets see if it matches.
|
||||
var childElements = xmlElement.Elements().ElementAt(0).Elements(name).ToArray();
|
||||
if (childElements.Any())
|
||||
{
|
||||
//we've found a match by the first child of an element called 'root' (strange, but sure)
|
||||
return new Attempt<IEnumerable<XElement>>(true, childElements);
|
||||
}
|
||||
}
|
||||
return base.TryGetMember(binder, out result);
|
||||
|
||||
//no deal
|
||||
return Attempt<IEnumerable<XElement>>.False;
|
||||
}
|
||||
|
||||
private bool HandleIEnumerableXElement(IEnumerable<XElement> elements, out object result)
|
||||
@@ -193,7 +330,7 @@ namespace Umbraco.Core.Dynamics
|
||||
//We have more than one matching element, so let's return the collection
|
||||
//elements is IEnumerable<DynamicXml>
|
||||
//but we want to be able to re-enter this code
|
||||
XElement root = new XElement(XName.Get("root"));
|
||||
var root = new XElement(XName.Get("root"));
|
||||
root.Add(elements);
|
||||
result = new DynamicXml(root);
|
||||
|
||||
@@ -205,10 +342,16 @@ namespace Umbraco.Core.Dynamics
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes an XPath expression over the BaseElement object
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public DynamicXml XPath(string expression)
|
||||
{
|
||||
var matched = this.BaseElement.XPathSelectElements(expression);
|
||||
DynamicXml root = new DynamicXml("<results/>");
|
||||
var matched = BaseElement.XPathSelectElements(expression);
|
||||
var root = new DynamicXml("<results/>");
|
||||
foreach (var element in matched)
|
||||
{
|
||||
root.BaseElement.Add(element);
|
||||
@@ -217,7 +360,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the string version of Xml
|
||||
/// Return the string version of the BaseElement object
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
@@ -231,23 +374,23 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public DynamicXml Find(string expression)
|
||||
{
|
||||
return new DynamicXml(this.BaseElement.XPathSelectElements(expression).FirstOrDefault());
|
||||
return new DynamicXml(BaseElement.XPathSelectElements(expression).FirstOrDefault());
|
||||
}
|
||||
|
||||
public DynamicXml Find(string attributeName, object value)
|
||||
{
|
||||
string expression = string.Format("//*[{0}='{1}']", attributeName, value);
|
||||
return new DynamicXml(this.BaseElement.XPathSelectElements(expression).FirstOrDefault());
|
||||
return new DynamicXml(BaseElement.XPathSelectElements(expression).FirstOrDefault());
|
||||
}
|
||||
|
||||
IEnumerator<XElement> IEnumerable<XElement>.GetEnumerator()
|
||||
{
|
||||
return this.BaseElement.Elements().GetEnumerator();
|
||||
return BaseElement.Elements().GetEnumerator();
|
||||
}
|
||||
|
||||
public IEnumerator<DynamicXml> GetEnumerator()
|
||||
{
|
||||
return this.BaseElement.Elements().Select(e => new DynamicXml(e)).GetEnumerator();
|
||||
return BaseElement.Elements().Select(e => new DynamicXml(e)).GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
@@ -310,7 +453,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public bool IsPosition(int index)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -318,7 +461,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public HtmlString IsPosition(int index, string valueIfTrue)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return new HtmlString(string.Empty);
|
||||
}
|
||||
@@ -326,7 +469,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public HtmlString IsPosition(int index, string valueIfTrue, string valueIfFalse)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return new HtmlString(valueIfFalse);
|
||||
}
|
||||
@@ -334,7 +477,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public bool IsModZero(int modulus)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -342,7 +485,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public HtmlString IsModZero(int modulus, string valueIfTrue)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return new HtmlString(string.Empty);
|
||||
}
|
||||
@@ -350,7 +493,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public HtmlString IsModZero(int modulus, string valueIfTrue, string valueIfFalse)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return new HtmlString(valueIfFalse);
|
||||
}
|
||||
@@ -359,7 +502,7 @@ namespace Umbraco.Core.Dynamics
|
||||
|
||||
public bool IsNotModZero(int modulus)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || BaseElement.Parent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -367,7 +510,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public HtmlString IsNotModZero(int modulus, string valueIfTrue)
|
||||
{
|
||||
if (this.BaseElement == null || this.BaseElement.Parent == null)
|
||||
if (BaseElement == null || this.BaseElement.Parent == null)
|
||||
{
|
||||
return new HtmlString(string.Empty);
|
||||
}
|
||||
@@ -573,7 +716,8 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public IEnumerable<DynamicXml> Descendants(Func<XElement, bool> func)
|
||||
{
|
||||
var flattenedNodes = this.BaseElement.Elements().Map(func, (XElement n) => { return n.Elements(); });
|
||||
//var flattenedNodes = this.BaseElement.Elements().Map(func, n => n.Elements());
|
||||
var flattenedNodes = this.BaseElement.Elements().SelectMany(n => n.Elements()).Where(func);
|
||||
return flattenedNodes.ToList().ConvertAll(n => new DynamicXml(n));
|
||||
}
|
||||
public IEnumerable<DynamicXml> DescendantsOrSelf()
|
||||
@@ -582,7 +726,8 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
public IEnumerable<DynamicXml> DescendantsOrSelf(Func<XElement, bool> func)
|
||||
{
|
||||
var flattenedNodes = this.BaseElement.Elements().Map(func, (XElement n) => { return n.Elements(); });
|
||||
//var flattenedNodes = this.BaseElement.Elements().Map(func, n => n.Elements());
|
||||
var flattenedNodes = this.BaseElement.Elements().SelectMany(n => n.Elements()).Where(func);
|
||||
var list = new List<DynamicXml>();
|
||||
list.Add(this);
|
||||
list.AddRange(flattenedNodes.ToList().ConvertAll(n => new DynamicXml(n)));
|
||||
@@ -689,57 +834,10 @@ namespace Umbraco.Core.Dynamics
|
||||
return test(this) ? new HtmlString(valueIfTrue) : new HtmlString(valueIfFalse);
|
||||
}
|
||||
|
||||
[Obsolete("Use XmlHelper.StripDashesInElementOrAttributeNames instead")]
|
||||
public static string StripDashesInElementOrAttributeNames(string xml)
|
||||
{
|
||||
using (MemoryStream outputms = new MemoryStream())
|
||||
{
|
||||
using (TextWriter outputtw = new StreamWriter(outputms))
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (TextWriter tw = new StreamWriter(ms))
|
||||
{
|
||||
tw.Write(xml);
|
||||
tw.Flush();
|
||||
ms.Position = 0;
|
||||
using (TextReader tr = new StreamReader(ms))
|
||||
{
|
||||
bool IsInsideElement = false, IsInsideQuotes = false;
|
||||
int ic = 0;
|
||||
while ((ic = tr.Read()) != -1)
|
||||
{
|
||||
if (ic == (int)'<' && !IsInsideQuotes)
|
||||
{
|
||||
if (tr.Peek() != (int)'!')
|
||||
{
|
||||
IsInsideElement = true;
|
||||
}
|
||||
}
|
||||
if (ic == (int)'>' && !IsInsideQuotes)
|
||||
{
|
||||
IsInsideElement = false;
|
||||
}
|
||||
if (ic == (int)'"')
|
||||
{
|
||||
IsInsideQuotes = !IsInsideQuotes;
|
||||
}
|
||||
if (!IsInsideElement || ic != (int)'-' || IsInsideQuotes)
|
||||
{
|
||||
outputtw.Write((char)ic);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
outputtw.Flush();
|
||||
outputms.Position = 0;
|
||||
using (TextReader outputtr = new StreamReader(outputms))
|
||||
{
|
||||
return outputtr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
return XmlHelper.StripDashesInElementOrAttributeNames(xml);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,58 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to return the raw xml string value from DynamicXml when using type converters
|
||||
/// </summary>
|
||||
public class RawXmlString
|
||||
{
|
||||
public string Value { get; private set; }
|
||||
|
||||
public RawXmlString(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to return the raw xml XElement value from DynamicXml when using type converters
|
||||
/// </summary>
|
||||
public class RawXElement
|
||||
{
|
||||
public XElement Value { get; private set; }
|
||||
|
||||
public RawXElement(XElement value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to return the raw xml XElement value from DynamicXml when using type converters
|
||||
/// </summary>
|
||||
public class RawXmlElement
|
||||
{
|
||||
public XmlElement Value { get; private set; }
|
||||
|
||||
public RawXmlElement(XmlElement value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to return the raw xml XmlDocument value from DynamicXml when using type converters
|
||||
/// </summary>
|
||||
public class RawXmlDocument
|
||||
{
|
||||
public XmlDocument Value { get; private set; }
|
||||
|
||||
public RawXmlDocument(XmlDocument value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom type converter for DynamicXml
|
||||
/// </summary>
|
||||
@@ -14,7 +66,17 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
var convertableTypes = new[] {typeof(string), typeof(XElement), typeof(XmlElement), typeof(XmlDocument)};
|
||||
var convertableTypes = new[]
|
||||
{
|
||||
typeof(string),
|
||||
typeof(XElement),
|
||||
typeof(XmlElement),
|
||||
typeof(XmlDocument),
|
||||
typeof(RawXmlString),
|
||||
typeof(RawXElement),
|
||||
typeof(RawXmlElement),
|
||||
typeof(RawXmlDocument)
|
||||
};
|
||||
|
||||
return convertableTypes.Any(x => TypeHelper.IsTypeAssignableFrom(x, sourceType))
|
||||
|| base.CanConvertFrom(context, sourceType);
|
||||
@@ -34,6 +96,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
//XElement
|
||||
if (TypeHelper.IsTypeAssignableFrom<XElement>(destinationType))
|
||||
{
|
||||
@@ -53,6 +116,34 @@ namespace Umbraco.Core.Dynamics
|
||||
xDoc.LoadXml(dxml.ToString());
|
||||
return xDoc;
|
||||
}
|
||||
|
||||
//RAW values:
|
||||
//string
|
||||
if (TypeHelper.IsTypeAssignableFrom<RawXmlString>(destinationType))
|
||||
{
|
||||
return new RawXmlString(dxml.ToRawXml());
|
||||
}
|
||||
//XElement
|
||||
if (TypeHelper.IsTypeAssignableFrom<RawXElement>(destinationType))
|
||||
{
|
||||
return new RawXElement(dxml.RawXmlElement);
|
||||
}
|
||||
//XmlElement
|
||||
if (TypeHelper.IsTypeAssignableFrom<RawXmlElement>(destinationType))
|
||||
{
|
||||
var xDoc = new XmlDocument();
|
||||
xDoc.LoadXml(dxml.ToRawXml());
|
||||
return new RawXmlElement(xDoc.DocumentElement);
|
||||
}
|
||||
//XmlDocument
|
||||
if (TypeHelper.IsTypeAssignableFrom<RawXmlDocument>(destinationType))
|
||||
{
|
||||
var xDoc = new XmlDocument();
|
||||
xDoc.LoadXml(dxml.ToRawXml());
|
||||
return new RawXmlDocument(xDoc);
|
||||
}
|
||||
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,36 +5,35 @@ using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
[Obsolete("This class should not be used, it is just referenced by already obsoleted code and will be removed in the future")]
|
||||
internal static class ExtensionMethods
|
||||
{
|
||||
public static IEnumerable<TSource> Map<TSource>(
|
||||
this IEnumerable<TSource> source,
|
||||
Func<TSource, bool> selectorFunction,
|
||||
Func<TSource, IEnumerable<TSource>> getChildrenFunction)
|
||||
{
|
||||
if (!source.Any())
|
||||
{
|
||||
return source;
|
||||
}
|
||||
// Add what we have to the stack
|
||||
var flattenedList = source.Where(selectorFunction);
|
||||
// Go through the input enumerable looking for children,
|
||||
// and add those if we have them
|
||||
foreach (TSource element in source)
|
||||
{
|
||||
var secondInner = getChildrenFunction(element);
|
||||
if (secondInner.Any())
|
||||
{
|
||||
secondInner = secondInner.Map(selectorFunction, getChildrenFunction);
|
||||
}
|
||||
flattenedList = flattenedList.Concat(secondInner);
|
||||
}
|
||||
return flattenedList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//public static IEnumerable<TSource> Map<TSource>(
|
||||
// this IEnumerable<TSource> source,
|
||||
// Func<TSource, bool> selectorFunction,
|
||||
// Func<TSource, IEnumerable<TSource>> getChildrenFunction)
|
||||
//{
|
||||
// if (!source.Any())
|
||||
// {
|
||||
// return source;
|
||||
// }
|
||||
// // Add what we have to the stack
|
||||
// var flattenedList = source.Where(selectorFunction);
|
||||
// // Go through the input enumerable looking for children,
|
||||
// // and add those if we have them
|
||||
// foreach (TSource element in source)
|
||||
// {
|
||||
// var secondInner = getChildrenFunction(element);
|
||||
// if (secondInner.Any())
|
||||
// {
|
||||
// secondInner = secondInner.Map(selectorFunction, getChildrenFunction);
|
||||
// }
|
||||
// flattenedList = flattenedList.Concat(secondInner);
|
||||
// }
|
||||
// return flattenedList;
|
||||
//}
|
||||
|
||||
[Obsolete("This method should not be used and will be removed in the future")]
|
||||
public static bool ContainsAny(this string haystack, IEnumerable<string> needles)
|
||||
{
|
||||
if (haystack == null) throw new ArgumentNullException("haystack");
|
||||
@@ -44,6 +43,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
return false;
|
||||
}
|
||||
[Obsolete("This method should not be used and will be removed in the future")]
|
||||
public static bool ContainsAny(this string haystack, params string[] needles)
|
||||
{
|
||||
if (haystack == null) throw new ArgumentNullException("haystack");
|
||||
@@ -53,6 +53,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
return false;
|
||||
}
|
||||
[Obsolete("This method should not be used and will be removed in the future")]
|
||||
public static bool ContainsAny(this string haystack, StringComparison comparison, IEnumerable<string> needles)
|
||||
{
|
||||
if (haystack == null) throw new ArgumentNullException("haystack");
|
||||
@@ -62,6 +63,7 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
return false;
|
||||
}
|
||||
[Obsolete("This method should not be used and will be removed in the future")]
|
||||
public static bool ContainsAny(this string haystack, StringComparison comparison, params string[] needles)
|
||||
{
|
||||
if (haystack == null) throw new ArgumentNullException("haystack");
|
||||
@@ -71,12 +73,13 @@ namespace Umbraco.Core.Dynamics
|
||||
}
|
||||
return false;
|
||||
}
|
||||
[Obsolete("This method should not be used and will be removed in the future")]
|
||||
public static bool ContainsInsensitive(this string haystack, string needle)
|
||||
{
|
||||
if (haystack == null) throw new ArgumentNullException("haystack");
|
||||
return haystack.IndexOf(needle, StringComparison.CurrentCultureIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
[Obsolete("This method should not be used and will be removed in the future")]
|
||||
public static bool HasValue(this string s)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(s);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
// Provides information on the macro that caused an error
|
||||
public class MacroErrorEventArgs : System.EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the faulting macro.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alias of the faulting macro.
|
||||
/// </summary>
|
||||
public string Alias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filename, file path, fully qualified class name, or other key used by the macro engine to do it's processing of the faulting macro.
|
||||
/// </summary>
|
||||
public string ItemKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Exception raised.
|
||||
/// </summary>
|
||||
public Exception Exception { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the desired behaviour when a matching macro causes an error. See
|
||||
/// <see cref="MacroErrorBehaviour"/> for definitions. By setting this in your event
|
||||
/// you can override the default behaviour defined in UmbracoSettings.config.
|
||||
/// </summary>
|
||||
/// <value>Macro error behaviour enum.</value>
|
||||
public MacroErrorBehaviour Behaviour { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using System.IO;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
@@ -230,6 +231,20 @@ namespace Umbraco.Core.IO
|
||||
filePath = String.Empty;
|
||||
}
|
||||
|
||||
//Break up the file in name and extension before applying the UrlReplaceCharacters
|
||||
var fileNamePart = filePath.Substring(0, filePath.LastIndexOf('.'));
|
||||
var ext = filePath.Substring(filePath.LastIndexOf('.'));
|
||||
|
||||
//Because the file usually is downloadable as well we check characters against 'UmbracoSettings.UrlReplaceCharacters'
|
||||
XmlNode replaceChars = UmbracoSettings.UrlReplaceCharacters;
|
||||
foreach (XmlNode n in replaceChars.SelectNodes("char"))
|
||||
{
|
||||
if (n.Attributes.GetNamedItem("org") != null && n.Attributes.GetNamedItem("org").Value != "")
|
||||
fileNamePart = fileNamePart.Replace(n.Attributes.GetNamedItem("org").Value, XmlHelper.GetNodeValue(n));
|
||||
}
|
||||
|
||||
filePath = string.Concat(fileNamePart, ext);
|
||||
|
||||
// Adapted from: http://stackoverflow.com/a/4827510/5018
|
||||
// Combined both Reserved Characters and Character Data
|
||||
// from http://en.wikipedia.org/wiki/Percent-encoding
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Umbraco.Core.CodeAnnotations;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
@@ -27,6 +25,15 @@ namespace Umbraco.Core.IO
|
||||
return propertyId.ToString() + seperator + fileName;
|
||||
}
|
||||
|
||||
public string GetRelativePath(string subfolder, string fileName)
|
||||
{
|
||||
var seperator = UmbracoSettings.UploadAllowDirectories
|
||||
? Path.DirectorySeparatorChar
|
||||
: '-';
|
||||
|
||||
return subfolder + seperator + fileName;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetThumbnails(string path)
|
||||
{
|
||||
var parentDirectory = System.IO.Path.GetDirectoryName(path);
|
||||
|
||||
@@ -183,16 +183,26 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
}
|
||||
|
||||
private static string _root;
|
||||
/// <summary>
|
||||
/// Gets the root path of the application
|
||||
/// </summary>
|
||||
public static string Root
|
||||
{
|
||||
get
|
||||
{
|
||||
string appPath = HttpRuntime.AppDomainAppVirtualPath ?? string.Empty;
|
||||
if (appPath == "/")
|
||||
appPath = string.Empty;
|
||||
if (_root == null)
|
||||
{
|
||||
string appPath = HttpRuntime.AppDomainAppVirtualPath ?? string.Empty;
|
||||
if (appPath == "/")
|
||||
appPath = string.Empty;
|
||||
|
||||
return appPath;
|
||||
_root = appPath;
|
||||
}
|
||||
return _root;
|
||||
}
|
||||
//Only required for unit tests
|
||||
internal set { _root = value; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public enum IconPickerBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Default umbraco behavior - show duplicates in files and sprites
|
||||
/// </summary>
|
||||
ShowDuplicates,
|
||||
|
||||
/// <summary>
|
||||
/// If a file exists on disk with the same name as one in the sprite
|
||||
/// then the file on disk overrules the one in the sprite, the
|
||||
/// sprite icon will not be shown
|
||||
/// </summary>
|
||||
HideSpriteDuplicates,
|
||||
|
||||
/// <summary>
|
||||
/// If a file exists on disk with the same name as one in the sprite
|
||||
/// then the file in the sprite overrules the one on disk, the file
|
||||
/// on disk will be shown
|
||||
/// </summary>
|
||||
HideFileDuplicates
|
||||
}
|
||||
}
|
||||
@@ -64,23 +64,28 @@ namespace Umbraco.Core.Logging
|
||||
{
|
||||
_forceStop = true;
|
||||
var windowsIdentity = WindowsIdentity.GetCurrent();
|
||||
base.Append(new LoggingEvent(new LoggingEventData
|
||||
{
|
||||
Level = Level.Error,
|
||||
Message =
|
||||
"Unable to clear out the AsynchronousRollingFileAppender buffer in the allotted time, forcing a shutdown",
|
||||
TimeStamp = DateTime.UtcNow,
|
||||
Identity = "",
|
||||
ExceptionString = "",
|
||||
UserName = windowsIdentity != null ? windowsIdentity.Name : "",
|
||||
Domain = AppDomain.CurrentDomain.FriendlyName,
|
||||
ThreadName = Thread.CurrentThread.ManagedThreadId.ToString(),
|
||||
LocationInfo =
|
||||
new LocationInfo(this.GetType().Name, "OnClose", "AsynchronousRollingFileAppender.cs", "59"),
|
||||
LoggerName = this.GetType().FullName,
|
||||
Properties = new PropertiesDictionary(),
|
||||
})
|
||||
);
|
||||
|
||||
var logEvent = new LoggingEvent(new LoggingEventData
|
||||
{
|
||||
Level = global::log4net.Core.Level.Error,
|
||||
Message =
|
||||
"Unable to clear out the AsynchronousRollingFileAppender buffer in the allotted time, forcing a shutdown",
|
||||
TimeStamp = DateTime.UtcNow,
|
||||
Identity = "",
|
||||
ExceptionString = "",
|
||||
UserName = windowsIdentity != null ? windowsIdentity.Name : "",
|
||||
Domain = AppDomain.CurrentDomain.FriendlyName,
|
||||
ThreadName = Thread.CurrentThread.ManagedThreadId.ToString(),
|
||||
LocationInfo =
|
||||
new LocationInfo(this.GetType().Name, "OnClose", "AsynchronousRollingFileAppender.cs", "59"),
|
||||
LoggerName = this.GetType().FullName,
|
||||
Properties = new PropertiesDictionary(),
|
||||
});
|
||||
|
||||
if (this.DateTimeStrategy != null)
|
||||
{
|
||||
base.Append(logEvent);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnClose();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public enum MacroErrorBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Default umbraco behavior - show an inline error within the
|
||||
/// macro but allow the page to continue rendering.
|
||||
/// </summary>
|
||||
Inline,
|
||||
|
||||
/// <summary>
|
||||
/// Silently eat the error and do not display the offending macro.
|
||||
/// </summary>
|
||||
Silent,
|
||||
|
||||
/// <summary>
|
||||
/// Throw an exception which can be caught by the global error handler
|
||||
/// defined in Application_OnError. If no such error handler is defined
|
||||
/// then you'll see the Yellow Screen Of Death (YSOD) error page.
|
||||
/// </summary>
|
||||
Throw
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Media
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal singleton to handle the numbering of subfolders within the Media-folder.
|
||||
/// When this class is initiated it will look for numbered subfolders and select the highest number,
|
||||
/// which will be the start point for the naming of the next subfolders. If no subfolders exists
|
||||
/// then the starting point will be 1000, ie. /media/1000/koala.jpg
|
||||
/// </summary>
|
||||
internal class MediaSubfolderCounter
|
||||
{
|
||||
#region Singleton
|
||||
|
||||
private long _numberedFolder = 1000;//Default starting point
|
||||
private static readonly ReaderWriterLockSlim ClearLock = new ReaderWriterLockSlim();
|
||||
private static readonly Lazy<MediaSubfolderCounter> Lazy = new Lazy<MediaSubfolderCounter>(() => new MediaSubfolderCounter());
|
||||
|
||||
public static MediaSubfolderCounter Current { get { return Lazy.Value; } }
|
||||
|
||||
private MediaSubfolderCounter()
|
||||
{
|
||||
var folders = new List<long>();
|
||||
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
|
||||
var directories = fs.GetDirectories("");
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
long dirNum;
|
||||
if (long.TryParse(directory, out dirNum))
|
||||
{
|
||||
folders.Add(dirNum);
|
||||
}
|
||||
}
|
||||
var last = folders.OrderBy(x => x).LastOrDefault();
|
||||
if(last != default(long))
|
||||
_numberedFolder = last;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns an increment of the numbered media subfolders.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.Int64"/> value</returns>
|
||||
public long Increment()
|
||||
{
|
||||
using (new ReadLock(ClearLock))
|
||||
{
|
||||
_numberedFolder = _numberedFolder + 1;
|
||||
return _numberedFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Media;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
@@ -57,16 +58,22 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFileBase object as the property value
|
||||
/// </summary>
|
||||
/// <param name="content"><see cref="IContent"/> to add property value to</param>
|
||||
/// <param name="content"><see cref="IContentBase"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="value">The <see cref="HttpPostedFileBase"/> containing the file that will be uploaded</param>
|
||||
public static void SetValue(this IContentBase content, string propertyTypeAlias, HttpPostedFileBase value)
|
||||
{
|
||||
// Ensure we get the filename without the path in IE in intranet mode
|
||||
// http://stackoverflow.com/questions/382464/httppostedfile-filename-different-from-ie
|
||||
var fileName = value.FileName;
|
||||
if (fileName.LastIndexOf(@"\") > 0)
|
||||
fileName = fileName.Substring(fileName.LastIndexOf(@"\") + 1);
|
||||
|
||||
var name =
|
||||
IOHelper.SafeFileName(
|
||||
value.FileName.Substring(value.FileName.LastIndexOf(IOHelper.DirSepChar) + 1,
|
||||
value.FileName.Length - value.FileName.LastIndexOf(IOHelper.DirSepChar) - 1)
|
||||
.ToLower());
|
||||
fileName.Substring(fileName.LastIndexOf(IOHelper.DirSepChar) + 1,
|
||||
fileName.Length - fileName.LastIndexOf(IOHelper.DirSepChar) - 1)
|
||||
.ToLower());
|
||||
|
||||
if (string.IsNullOrEmpty(name) == false)
|
||||
SetFileOnContent(content, propertyTypeAlias, name, value.InputStream);
|
||||
@@ -75,16 +82,22 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFile object as the property value
|
||||
/// </summary>
|
||||
/// <param name="content"><see cref="IContent"/> to add property value to</param>
|
||||
/// <param name="content"><see cref="IContentBase"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="value">The <see cref="HttpPostedFile"/> containing the file that will be uploaded</param>
|
||||
public static void SetValue(this IContentBase content, string propertyTypeAlias, HttpPostedFile value)
|
||||
{
|
||||
// Ensure we get the filename without the path in IE in intranet mode
|
||||
// http://stackoverflow.com/questions/382464/httppostedfile-filename-different-from-ie
|
||||
var fileName = value.FileName;
|
||||
if (fileName.LastIndexOf(@"\") > 0)
|
||||
fileName = fileName.Substring(fileName.LastIndexOf(@"\") + 1);
|
||||
|
||||
var name =
|
||||
IOHelper.SafeFileName(
|
||||
value.FileName.Substring(value.FileName.LastIndexOf(IOHelper.DirSepChar) + 1,
|
||||
value.FileName.Length - value.FileName.LastIndexOf(IOHelper.DirSepChar) - 1)
|
||||
.ToLower());
|
||||
fileName.Substring(fileName.LastIndexOf(IOHelper.DirSepChar) + 1,
|
||||
fileName.Length - fileName.LastIndexOf(IOHelper.DirSepChar) - 1)
|
||||
.ToLower());
|
||||
|
||||
if (string.IsNullOrEmpty(name) == false)
|
||||
SetFileOnContent(content, propertyTypeAlias, name, value.InputStream);
|
||||
@@ -93,13 +106,37 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFileWrapper object as the property value
|
||||
/// </summary>
|
||||
/// <param name="content"><see cref="IContent"/> to add property value to</param>
|
||||
/// <param name="content"><see cref="IContentBase"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="value">The <see cref="HttpPostedFileWrapper"/> containing the file that will be uploaded</param>
|
||||
public static void SetValue(this IContentBase content, string propertyTypeAlias, HttpPostedFileWrapper value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value.FileName) == false)
|
||||
SetFileOnContent(content, propertyTypeAlias, value.FileName, value.InputStream);
|
||||
// Ensure we get the filename without the path in IE in intranet mode
|
||||
// http://stackoverflow.com/questions/382464/httppostedfile-filename-different-from-ie
|
||||
var fileName = value.FileName;
|
||||
if (fileName.LastIndexOf(@"\") > 0)
|
||||
fileName = fileName.Substring(fileName.LastIndexOf(@"\") + 1);
|
||||
|
||||
var name = IOHelper.SafeFileName(fileName);
|
||||
|
||||
if (string.IsNullOrEmpty(name) == false)
|
||||
SetFileOnContent(content, propertyTypeAlias, name, value.InputStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a <see cref="Stream"/> as the property value
|
||||
/// </summary>
|
||||
/// <param name="content"><see cref="IContentBase"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="fileName">Name of the file</param>
|
||||
/// <param name="fileStream"><see cref="Stream"/> to save to disk</param>
|
||||
public static void SetValue(this IContentBase content, string propertyTypeAlias, string fileName,
|
||||
Stream fileStream)
|
||||
{
|
||||
var name = IOHelper.SafeFileName(fileName);
|
||||
|
||||
if (string.IsNullOrEmpty(name) == false && fileStream != null)
|
||||
SetFileOnContent(content, propertyTypeAlias, name, fileStream);
|
||||
}
|
||||
|
||||
private static void SetFileOnContent(IContentBase content, string propertyTypeAlias, string name, Stream fileStream)
|
||||
@@ -109,10 +146,12 @@ namespace Umbraco.Core.Models
|
||||
return;
|
||||
|
||||
bool supportsResizing = false;
|
||||
var numberedFolder = MediaSubfolderCounter.Current.Increment();
|
||||
string fileName = UmbracoSettings.UploadAllowDirectories
|
||||
? Path.Combine(property.Id.ToString(), name)
|
||||
: property.Id + "-" + name;
|
||||
string extension = Path.GetExtension(name);
|
||||
? Path.Combine(numberedFolder.ToString(CultureInfo.InvariantCulture), name)
|
||||
: numberedFolder + "-" + name;
|
||||
|
||||
string extension = Path.GetExtension(name).Substring(1).ToLowerInvariant();
|
||||
|
||||
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
|
||||
fs.AddFile(fileName, fileStream);
|
||||
@@ -182,7 +221,7 @@ namespace Umbraco.Core.Models
|
||||
private static void SetPropertyValue(IContentBase content, XmlNode uploadFieldConfigNode, string propertyAlias, string propertyValue)
|
||||
{
|
||||
XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias);
|
||||
if (propertyNode != null && string.IsNullOrEmpty(propertyNode.FirstChild.Value) == false)
|
||||
if (propertyNode != null && string.IsNullOrEmpty(propertyNode.FirstChild.Value) == false && content.HasProperty(propertyNode.FirstChild.Value))
|
||||
{
|
||||
content.SetValue(propertyNode.FirstChild.Value, propertyValue);
|
||||
}
|
||||
@@ -407,7 +446,7 @@ namespace Umbraco.Core.Models
|
||||
//Check for umbracoUrlName convention
|
||||
if (property.Alias == "umbracoUrlName" && property.Value != null &&
|
||||
property.Value.ToString().Trim() != string.Empty)
|
||||
xml.SetAttributeValue("urlName", property.Value);
|
||||
xml.SetAttributeValue("urlName", property.Value.ToString().FormatUrl().ToLower());
|
||||
}
|
||||
|
||||
return xml;
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -323,6 +322,74 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a PropertyType with a given alias already exists
|
||||
/// </summary>
|
||||
/// <param name="propertyTypeAlias">Alias of the PropertyType</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyType with the passed in alias exists, otherwise <c>False</c></returns>
|
||||
public abstract bool PropertyTypeExists(string propertyTypeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyGroup.
|
||||
/// This method will also check if a group already exists with the same name and link it to the parent.
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the PropertyGroup to add</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
|
||||
public abstract bool AddPropertyGroup(string groupName);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType to a specific PropertyGroup
|
||||
/// </summary>
|
||||
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
|
||||
/// <param name="propertyGroupName">Name of the PropertyGroup to add the PropertyType to</param>
|
||||
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
|
||||
public abstract bool AddPropertyType(PropertyType propertyType, string propertyGroupName);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType, which does not belong to a PropertyGroup.
|
||||
/// </summary>
|
||||
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
|
||||
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
|
||||
public bool AddPropertyType(PropertyType propertyType)
|
||||
{
|
||||
if (PropertyTypeExists(propertyType.Alias) == false)
|
||||
{
|
||||
_propertyTypes.Add(propertyType);
|
||||
_propertyTypes.CollectionChanged += PropertyTypesChanged;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves a PropertyType to a specified PropertyGroup
|
||||
/// </summary>
|
||||
/// <param name="propertyTypeAlias">Alias of the PropertyType to move</param>
|
||||
/// <param name="propertyGroupName">Name of the PropertyGroup to move the PropertyType to</param>
|
||||
/// <returns></returns>
|
||||
public bool MovePropertyType(string propertyTypeAlias, string propertyGroupName)
|
||||
{
|
||||
if (PropertyTypes.Any(x => x.Alias == propertyTypeAlias) == false || PropertyGroups.Any(x => x.Name == propertyGroupName) == false)
|
||||
return false;
|
||||
|
||||
var propertyType = PropertyTypes.First(x => x.Alias == propertyTypeAlias);
|
||||
//The PropertyType already belongs to a PropertyGroup, so we have to remove the PropertyType from that group
|
||||
if (PropertyGroups.Any(x => x.PropertyTypes.Any(y => y.Alias == propertyTypeAlias)))
|
||||
{
|
||||
var oldPropertyGroup = PropertyGroups.First(x => x.PropertyTypes.Any(y => y.Alias == propertyTypeAlias));
|
||||
oldPropertyGroup.PropertyTypes.RemoveItem(propertyTypeAlias);
|
||||
}
|
||||
|
||||
propertyType.PropertyGroupId = new Lazy<int>(() => default(int));
|
||||
propertyType.ResetDirtyProperties();
|
||||
|
||||
var propertyGroup = PropertyGroups.First(x => x.Name == propertyGroupName);
|
||||
propertyGroup.PropertyTypes.Add(propertyType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a PropertyType from the current ContentType
|
||||
/// </summary>
|
||||
@@ -333,6 +400,11 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
propertyGroup.PropertyTypes.RemoveItem(propertyTypeAlias);
|
||||
}
|
||||
|
||||
if (_propertyTypes.Any(x => x.Alias == propertyTypeAlias))
|
||||
{
|
||||
_propertyTypes.RemoveItem(propertyTypeAlias);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -343,9 +415,5 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
_parentId = id;
|
||||
}
|
||||
|
||||
//TODO Implement moving PropertyType between groups.
|
||||
/*public bool MovePropertyTypeToGroup(string propertyTypeAlias, string groupName)
|
||||
{}*/
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ namespace Umbraco.Core.Models
|
||||
public abstract class ContentTypeCompositionBase : ContentTypeBase, IContentTypeComposition
|
||||
{
|
||||
private readonly List<IContentTypeComposition> _contentTypeComposition = new List<IContentTypeComposition>();
|
||||
internal List<int> RemovedContentTypeKeyTracker = new List<int>();
|
||||
|
||||
protected ContentTypeCompositionBase(int parentId) : base(parentId)
|
||||
{
|
||||
@@ -44,7 +45,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
var groups = PropertyGroups.Union(ContentTypeComposition.SelectMany(x => x.CompositionPropertyGroups));
|
||||
var groups = ContentTypeComposition.SelectMany(x => x.CompositionPropertyGroups).Union(PropertyGroups);
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
@@ -57,8 +58,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
var propertyTypes =
|
||||
PropertyTypes.Union(ContentTypeComposition.SelectMany(x => x.CompositionPropertyTypes));
|
||||
var propertyTypes = ContentTypeComposition.SelectMany(x => x.CompositionPropertyTypes).Union(PropertyTypes);
|
||||
return propertyTypes;
|
||||
}
|
||||
}
|
||||
@@ -89,9 +89,11 @@ namespace Umbraco.Core.Models
|
||||
/// <returns>True if ContentType was removed, otherwise returns False</returns>
|
||||
public bool RemoveContentType(string alias)
|
||||
{
|
||||
if (!ContentTypeCompositionExists(alias))
|
||||
if (ContentTypeCompositionExists(alias))
|
||||
{
|
||||
var contentTypeComposition = ContentTypeComposition.First(x => x.Alias == alias);
|
||||
RemovedContentTypeKeyTracker.Add(contentTypeComposition.Id);
|
||||
OnPropertyChanged(ContentTypeCompositionSelector);
|
||||
return _contentTypeComposition.Remove(contentTypeComposition);
|
||||
}
|
||||
return false;
|
||||
@@ -113,6 +115,83 @@ namespace Umbraco.Core.Models
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a PropertyType with a given alias already exists
|
||||
/// </summary>
|
||||
/// <param name="propertyTypeAlias">Alias of the PropertyType</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyType with the passed in alias exists, otherwise <c>False</c></returns>
|
||||
public override bool PropertyTypeExists(string propertyTypeAlias)
|
||||
{
|
||||
return CompositionPropertyTypes.Any(x => x.Alias == propertyTypeAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyGroup.
|
||||
/// This method will also check if a group already exists with the same name and link it to the parent.
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the PropertyGroup to add</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
|
||||
public override bool AddPropertyGroup(string groupName)
|
||||
{
|
||||
if (PropertyGroups.Any(x => x.Name == groupName))
|
||||
return false;
|
||||
|
||||
var propertyGroup = new PropertyGroup {Name = groupName, SortOrder = 0};
|
||||
|
||||
if (CompositionPropertyGroups.Any(x => x.Name == groupName))
|
||||
{
|
||||
var firstGroup = CompositionPropertyGroups.First(x => x.Name == groupName && x.ParentId.HasValue == false);
|
||||
propertyGroup.SetLazyParentId(new Lazy<int?>(() => firstGroup.Id));
|
||||
}
|
||||
|
||||
if (PropertyGroups.Any())
|
||||
{
|
||||
var last = PropertyGroups.Last();
|
||||
propertyGroup.SortOrder = last.SortOrder + 1;
|
||||
}
|
||||
|
||||
PropertyGroups.Add(propertyGroup);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType to a specific PropertyGroup
|
||||
/// </summary>
|
||||
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
|
||||
/// <param name="propertyGroupName">Name of the PropertyGroup to add the PropertyType to</param>
|
||||
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
|
||||
public override bool AddPropertyType(PropertyType propertyType, string propertyGroupName)
|
||||
{
|
||||
if (PropertyTypeExists(propertyType.Alias) == false)
|
||||
{
|
||||
if (PropertyGroups.Contains(propertyGroupName))
|
||||
{
|
||||
propertyType.PropertyGroupId = new Lazy<int>(() => PropertyGroups[propertyGroupName].Id);
|
||||
PropertyGroups[propertyGroupName].PropertyTypes.Add(propertyType);
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the PropertyGroup doesn't already exist we create a new one
|
||||
var propertyTypes = new List<PropertyType> { propertyType };
|
||||
var propertyGroup = new PropertyGroup(new PropertyTypeCollection(propertyTypes)) { Name = propertyGroupName, SortOrder = 1 };
|
||||
//and check if its an inherited PropertyGroup, which exists in the composition
|
||||
if (CompositionPropertyGroups.Any(x => x.Name == propertyGroupName))
|
||||
{
|
||||
var parentPropertyGroup = CompositionPropertyGroups.First(x => x.Name == propertyGroupName && x.ParentId.HasValue == false);
|
||||
propertyGroup.SortOrder = parentPropertyGroup.SortOrder;
|
||||
//propertyGroup.ParentId = parentPropertyGroup.Id;
|
||||
propertyGroup.SetLazyParentId(new Lazy<int?>(() => parentPropertyGroup.Id));
|
||||
}
|
||||
|
||||
PropertyGroups.Add(propertyGroup);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of ContentType aliases from the current composition
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,17 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public class ContentTypeSort : IValueObject
|
||||
{
|
||||
public ContentTypeSort()
|
||||
{
|
||||
}
|
||||
|
||||
public ContentTypeSort(Lazy<int> id, int sortOrder, string @alias)
|
||||
{
|
||||
Id = id;
|
||||
SortOrder = sortOrder;
|
||||
Alias = alias;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the ContentType
|
||||
/// </summary>
|
||||
|
||||
@@ -15,12 +15,12 @@ namespace Umbraco.Core.Models
|
||||
public enum DataTypeDatabaseType
|
||||
{
|
||||
[EnumMember]
|
||||
Integer,
|
||||
[EnumMember]
|
||||
Date,
|
||||
Ntext,
|
||||
[EnumMember]
|
||||
Nvarchar,
|
||||
[EnumMember]
|
||||
Ntext /*, Object*/
|
||||
Integer,
|
||||
[EnumMember]
|
||||
Date
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,9 @@ namespace Umbraco.Core.Models
|
||||
internal override void AddingEntity()
|
||||
{
|
||||
base.AddingEntity();
|
||||
Key = Guid.NewGuid();
|
||||
|
||||
if(Key == default(Guid))
|
||||
Key = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,15 @@ namespace Umbraco.Core.Models.EntityBase
|
||||
[DataMember]
|
||||
public DateTime UpdateDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the WasCancelled flag, which is used to track
|
||||
/// whether some action against an entity was cancelled through some event.
|
||||
/// This only exists so we have a way to check if an event was cancelled through
|
||||
/// the new api, which also needs to take effect in the legacy api.
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
internal bool WasCancelled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Property changed event
|
||||
/// </summary>
|
||||
@@ -159,19 +168,6 @@ namespace Umbraco.Core.Models.EntityBase
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(Entity left, Entity right)
|
||||
{
|
||||
if (ReferenceEquals(null, left))
|
||||
return false;
|
||||
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(Entity left, Entity right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public virtual bool SameIdentityAs(IEntity other)
|
||||
{
|
||||
if (ReferenceEquals(null, other))
|
||||
|
||||
@@ -69,5 +69,43 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the Parent</param>
|
||||
void SetLazyParentId(Lazy<int> id);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a PropertyType with a given alias already exists
|
||||
/// </summary>
|
||||
/// <param name="propertyTypeAlias">Alias of the PropertyType</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyType with the passed in alias exists, otherwise <c>False</c></returns>
|
||||
bool PropertyTypeExists(string propertyTypeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType to a specific PropertyGroup
|
||||
/// </summary>
|
||||
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
|
||||
/// <param name="propertyGroupName">Name of the PropertyGroup to add the PropertyType to</param>
|
||||
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
|
||||
bool AddPropertyType(PropertyType propertyType, string propertyGroupName);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType, which does not belong to a PropertyGroup.
|
||||
/// </summary>
|
||||
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
|
||||
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
|
||||
bool AddPropertyType(PropertyType propertyType);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyGroup.
|
||||
/// This method will also check if a group already exists with the same name and link it to the parent.
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the PropertyGroup to add</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
|
||||
bool AddPropertyGroup(string groupName);
|
||||
|
||||
/// <summary>
|
||||
/// Moves a PropertyType to a specified PropertyGroup
|
||||
/// </summary>
|
||||
/// <param name="propertyTypeAlias">Alias of the PropertyType to move</param>
|
||||
/// <param name="propertyGroupName">Name of the PropertyGroup to move the PropertyType to</param>
|
||||
/// <returns></returns>
|
||||
bool MovePropertyType(string propertyTypeAlias, string propertyGroupName);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
int SessionTimeout { get; set; }
|
||||
int StartContentId { get; set; }
|
||||
int StartMediaId { get; set; }
|
||||
string Lanuguage { get; set; }
|
||||
string Language { get; set; }
|
||||
bool DefaultToLiveEditing { get; set; }
|
||||
IEnumerable<string> Applications { get; set; }
|
||||
bool NoConsole { get; set; }
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
#region Implementation of IUser
|
||||
|
||||
[DataMember]
|
||||
public string Lanuguage { get; set; }
|
||||
public string Language { get; set; }
|
||||
[DataMember]
|
||||
public string Permissions { get; set; }
|
||||
[DataMember]
|
||||
|
||||
@@ -19,6 +19,14 @@ namespace Umbraco.Core.Models
|
||||
var xd = new XmlDocument();
|
||||
XmlNode xmlNode = xd.CreateNode(XmlNodeType.Element, nodeName, "");
|
||||
|
||||
//Add the property alias to the legacy schema
|
||||
if (UmbracoSettings.UseLegacyXmlSchema)
|
||||
{
|
||||
var alias = xd.CreateAttribute("alias");
|
||||
alias.Value = property.Alias.ToSafeAlias();
|
||||
xmlNode.Attributes.Append(alias);
|
||||
}
|
||||
|
||||
//This seems to fail during testing
|
||||
xmlNode.AppendChild(property.PropertyType.DataType(property.Id).Data.ToXMl(xd));
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Models
|
||||
public class PropertyGroup : Entity, IEquatable<PropertyGroup>
|
||||
{
|
||||
private string _name;
|
||||
private int? _parentId;
|
||||
private Lazy<int?> _parentId;
|
||||
private int _sortOrder;
|
||||
private PropertyTypeCollection _propertyTypes;
|
||||
|
||||
@@ -51,15 +51,24 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Name of the Group, which corresponds to the Tab-name in the UI
|
||||
/// Gets or sets the Id of the Parent PropertyGroup.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A Parent PropertyGroup corresponds to an inherited PropertyGroup from a composition.
|
||||
/// If a PropertyType is inserted into an inherited group then a new group will be created with an Id reference to the parent.
|
||||
/// </remarks>
|
||||
[DataMember]
|
||||
public int? ParentId
|
||||
{
|
||||
get { return _parentId; }
|
||||
get
|
||||
{
|
||||
if (_parentId == null)
|
||||
return default(int?);
|
||||
return _parentId.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_parentId = value;
|
||||
_parentId = new Lazy<int?>(() => value);
|
||||
OnPropertyChanged(ParentIdSelector);
|
||||
}
|
||||
}
|
||||
@@ -92,6 +101,15 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the ParentId from the lazy integer id
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the Parent</param>
|
||||
internal void SetLazyParentId(Lazy<int?> id)
|
||||
{
|
||||
_parentId = id;
|
||||
}
|
||||
|
||||
public bool Equals(PropertyGroup other)
|
||||
{
|
||||
//Check whether the compared object is null.
|
||||
|
||||
@@ -13,12 +13,11 @@ namespace Umbraco.Core.Models
|
||||
[DataContract(IsReference = true)]
|
||||
public class PropertyType : Entity, IEquatable<PropertyType>
|
||||
{
|
||||
//private SerializationService _service;
|
||||
private string _name;
|
||||
private string _alias;
|
||||
private string _description;
|
||||
private int _dataTypeDefinitionId;
|
||||
private int _propertyGroupId;
|
||||
private Lazy<int> _propertyGroupId;
|
||||
private Guid _dataTypeId;
|
||||
private DataTypeDatabaseType _dataTypeDatabaseType;
|
||||
private bool _mandatory;
|
||||
@@ -33,22 +32,12 @@ namespace Umbraco.Core.Models
|
||||
|
||||
DataTypeId = dataTypeDefinition.ControlId;
|
||||
DataTypeDatabaseType = dataTypeDefinition.DatabaseType;
|
||||
|
||||
EnsureSerializationService();
|
||||
}
|
||||
|
||||
internal PropertyType(Guid dataTypeControlId, DataTypeDatabaseType dataTypeDatabaseType)
|
||||
{
|
||||
DataTypeId = dataTypeControlId;
|
||||
DataTypeDatabaseType = dataTypeDatabaseType;
|
||||
|
||||
EnsureSerializationService();
|
||||
}
|
||||
|
||||
private void EnsureSerializationService()
|
||||
{
|
||||
/*var serviceStackSerializer = new ServiceStackXmlSerializer();
|
||||
_service = new SerializationService(serviceStackSerializer);*/
|
||||
}
|
||||
|
||||
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.Name);
|
||||
@@ -61,7 +50,7 @@ namespace Umbraco.Core.Models
|
||||
private static readonly PropertyInfo HelpTextSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.HelpText);
|
||||
private static readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo<PropertyType, int>(x => x.SortOrder);
|
||||
private static readonly PropertyInfo ValidationRegExpSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.ValidationRegExp);
|
||||
private static readonly PropertyInfo PropertyGroupIdSelector = ExpressionHelper.GetPropertyInfo<PropertyType, int>(x => x.PropertyGroupId);
|
||||
private static readonly PropertyInfo PropertyGroupIdSelector = ExpressionHelper.GetPropertyInfo<PropertyType, Lazy<int>>(x => x.PropertyGroupId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets of Sets the Name of the PropertyType
|
||||
@@ -153,7 +142,7 @@ namespace Umbraco.Core.Models
|
||||
/// Gets or Sets the PropertyGroup's Id for which this PropertyType belongs
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
internal int PropertyGroupId
|
||||
internal Lazy<int> PropertyGroupId
|
||||
{
|
||||
get { return _propertyGroupId; }
|
||||
set
|
||||
@@ -181,6 +170,7 @@ namespace Umbraco.Core.Models
|
||||
/// Gets of Sets the Help text for the current PropertyType
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
[Obsolete("Not used anywhere in the UI")]
|
||||
public string HelpText
|
||||
{
|
||||
get { return _helpText; }
|
||||
@@ -209,7 +199,7 @@ namespace Umbraco.Core.Models
|
||||
/// Gets or Sets the RegEx for validation of legacy DataTypes
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
internal string ValidationRegExp
|
||||
public string ValidationRegExp
|
||||
{
|
||||
get { return _validationRegExp; }
|
||||
set
|
||||
@@ -218,7 +208,6 @@ namespace Umbraco.Core.Models
|
||||
OnPropertyChanged(ValidationRegExpSelector);
|
||||
}
|
||||
}
|
||||
//Note that Validation should eventually come from PropertyEditors like in v5
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Property object from a "raw" database value.
|
||||
@@ -335,8 +324,8 @@ namespace Umbraco.Core.Models
|
||||
if (Mandatory && (value == null || string.IsNullOrEmpty(value.ToString())))
|
||||
return false;
|
||||
|
||||
//Check against Regular Expression for Legacy DataTypes
|
||||
if(!string.IsNullOrEmpty(ValidationRegExp))
|
||||
//Check against Regular Expression for Legacy DataTypes - Validation exists and value is not null:
|
||||
if(string.IsNullOrEmpty(ValidationRegExp) == false && (value != null && string.IsNullOrEmpty(value.ToString()) == false))
|
||||
{
|
||||
var regexPattern = new Regex(ValidationRegExp);
|
||||
return regexPattern.IsMatch(value.ToString());
|
||||
|
||||
@@ -28,12 +28,8 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
base.Path = path;
|
||||
ParentId = -1;
|
||||
Key = name.EncodeAsGuid();
|
||||
_name = name;
|
||||
_alias = alias;
|
||||
|
||||
CreateDate = DateTime.Now;
|
||||
UpdateDate = DateTime.Now;
|
||||
_name = name.Replace("/", ".").Replace("\\", "");
|
||||
_alias = alias.ToSafeAlias();
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
@@ -52,7 +48,7 @@ namespace Umbraco.Core.Models
|
||||
internal string NodePath { get; set; }
|
||||
|
||||
[DataMember]
|
||||
internal int MasterTemplateId { get; set; }
|
||||
internal Lazy<int> MasterTemplateId { get; set; }
|
||||
|
||||
[DataMember]
|
||||
internal string MasterTemplateAlias { get; set; }
|
||||
@@ -116,5 +112,17 @@ namespace Umbraco.Core.Models
|
||||
|
||||
return validFile && validExtension;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to call when Entity is being saved
|
||||
/// </summary>
|
||||
/// <remarks>Created date is set and a Unique key is assigned</remarks>
|
||||
internal override void AddingEntity()
|
||||
{
|
||||
base.AddingEntity();
|
||||
|
||||
if (Key == Guid.Empty)
|
||||
Key = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,27 +8,49 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <summary>
|
||||
/// A resolver to return all IApplicationEvents objects
|
||||
/// </summary>
|
||||
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>
|
||||
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationEventHandler>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
private readonly LegacyStartupHandlerResolver _legacyResolver;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="applicationEventHandlers"></param>
|
||||
internal ApplicationEventsResolver(IEnumerable<Type> applicationEventHandlers)
|
||||
: base(applicationEventHandlers)
|
||||
{
|
||||
|
||||
//create the legacy resolver and only include the legacy types
|
||||
_legacyResolver = new LegacyStartupHandlerResolver(
|
||||
applicationEventHandlers.Where(x => !TypeHelper.IsTypeAssignableFrom<IApplicationEventHandler>(x)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Override in order to only return types of IApplicationEventHandler and above,
|
||||
/// do not include the legacy types of IApplicationStartupHandler
|
||||
/// </summary>
|
||||
protected override IEnumerable<Type> InstanceTypes
|
||||
{
|
||||
get { return base.InstanceTypes.Where(TypeHelper.IsTypeAssignableFrom<IApplicationEventHandler>); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IApplicationEventHandler"/> implementations.
|
||||
/// </summary>
|
||||
public IEnumerable<IApplicationEventHandler> ApplicationEventHandlers
|
||||
{
|
||||
get { return Values.OfType<IApplicationEventHandler>(); }
|
||||
get { return Values; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create instances of all of the legacy startup handlers
|
||||
/// </summary>
|
||||
public void InstantiateLegacyStartupHanlders()
|
||||
{
|
||||
//this will instantiate them all
|
||||
var handlers = _legacyResolver.LegacyStartupHandlers;
|
||||
}
|
||||
|
||||
protected override bool SupportsClear
|
||||
{
|
||||
get { return false; }
|
||||
@@ -44,5 +66,19 @@ namespace Umbraco.Core.ObjectResolution
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
private class LegacyStartupHandlerResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>
|
||||
{
|
||||
internal LegacyStartupHandlerResolver(IEnumerable<Type> legacyStartupHandlers)
|
||||
: base(legacyStartupHandlers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<IApplicationStartupHandler> LegacyStartupHandlers
|
||||
{
|
||||
get { return Values; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
|
||||
namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class for lazily resolving types for a resolver
|
||||
/// </summary>
|
||||
/// <typeparam name="TResolver"></typeparam>
|
||||
/// <typeparam name="TResolved"></typeparam>
|
||||
/// <remarks>
|
||||
/// This is a special case resolver for when types get lazily resolved in order to resolve the actual types. This is useful
|
||||
/// for when there is some processing overhead (i.e. Type finding in assemblies) to return the Types used to instantiate the instances.
|
||||
/// In some these cases we don't want to have to type find during application startup, only when we need to resolve the instances.
|
||||
///
|
||||
/// Important notes about this resolver: This does not support Insert or Remove and therefore does not support any ordering unless
|
||||
/// the types are marked with the WeightedPluginAttribute.
|
||||
/// </remarks>
|
||||
internal abstract class LazyManyObjectsResolverBase<TResolver, TResolved> : ManyObjectsResolverBase<TResolver, TResolved>
|
||||
where TResolved : class
|
||||
where TResolver : class
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
protected LazyManyObjectsResolverBase(ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
|
||||
: base(scope)
|
||||
{
|
||||
}
|
||||
|
||||
protected LazyManyObjectsResolverBase(HttpContextBase httpContext)
|
||||
: base(httpContext)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a list of lazy types
|
||||
/// </summary>
|
||||
/// <param name="listOfLazyTypes"></param>
|
||||
/// <param name="scope"></param>
|
||||
protected LazyManyObjectsResolverBase(IEnumerable<Lazy<Type>> listOfLazyTypes, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
|
||||
: this(scope)
|
||||
{
|
||||
AddTypes(listOfLazyTypes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a delegate to return a list of types
|
||||
/// </summary>
|
||||
/// <param name="typeListDelegate"></param>
|
||||
/// <param name="scope"></param>
|
||||
protected LazyManyObjectsResolverBase(Func<IEnumerable<Type>> typeListDelegate, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
|
||||
: this(scope)
|
||||
{
|
||||
_listOfTypeListDelegates.Add(typeListDelegate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a list of lazy types
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <param name="listOfLazyTypes"></param>
|
||||
protected LazyManyObjectsResolverBase(HttpContextBase httpContext, IEnumerable<Lazy<Type>> listOfLazyTypes)
|
||||
: this(httpContext)
|
||||
{
|
||||
AddTypes(listOfLazyTypes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting a delegate to return a list of types
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <param name="typeListDelegate"></param>
|
||||
protected LazyManyObjectsResolverBase(HttpContextBase httpContext, Func<IEnumerable<Type>> typeListDelegate)
|
||||
: this(httpContext)
|
||||
{
|
||||
_listOfTypeListDelegates.Add(typeListDelegate);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly List<Lazy<Type>> _lazyTypeList = new List<Lazy<Type>>();
|
||||
private readonly List<Func<IEnumerable<Type>>> _listOfTypeListDelegates = new List<Func<IEnumerable<Type>>>();
|
||||
private List<Type> _resolvedTypes = null;
|
||||
private readonly ReaderWriterLockSlim _typeResolutionLock = new ReaderWriterLockSlim();
|
||||
|
||||
/// <summary>
|
||||
/// Used for unit tests
|
||||
/// </summary>
|
||||
internal bool HasResolvedTypes
|
||||
{
|
||||
get { return _resolvedTypes != null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Once this is called this will resolve all types registered in the lazy list
|
||||
/// </summary>
|
||||
protected override IEnumerable<Type> InstanceTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var lck = new UpgradeableReadLock(_typeResolutionLock))
|
||||
{
|
||||
var lazyTypeList = _lazyTypeList.Select(x => x.Value).ToArray();
|
||||
var listofTypeListDelegates = _listOfTypeListDelegates.SelectMany(x => x()).ToArray();
|
||||
|
||||
//we need to validate each resolved type now since we could not do it before when inserting the lazy delegates
|
||||
if (!HasResolvedTypes)
|
||||
{
|
||||
lck.UpgradeToWriteLock();
|
||||
|
||||
_resolvedTypes = new List<Type>();
|
||||
|
||||
//first iterate the lazy type list
|
||||
foreach (var l in lazyTypeList)
|
||||
{
|
||||
UpdateUniqueList(_resolvedTypes, l);
|
||||
}
|
||||
|
||||
//next iterate the list of list type delegates
|
||||
foreach (var l in listofTypeListDelegates)
|
||||
{
|
||||
UpdateUniqueList(_resolvedTypes, l);
|
||||
}
|
||||
}
|
||||
|
||||
return _resolvedTypes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateUniqueList(List<Type> uniqueList, Type toAdd)
|
||||
{
|
||||
EnsureCorrectType(toAdd);
|
||||
if (uniqueList.Contains(toAdd))
|
||||
{
|
||||
throw new InvalidOperationException("The Type " + toAdd + " already exists in the collection");
|
||||
}
|
||||
uniqueList.Add(toAdd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows adding of multiple lazy types at once
|
||||
/// </summary>
|
||||
/// <param name="types"></param>
|
||||
protected void AddTypes(IEnumerable<Lazy<Type>> types)
|
||||
{
|
||||
EnsureAddSupport();
|
||||
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
foreach (var t in types)
|
||||
{
|
||||
_lazyTypeList.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a type list delegate to the collection
|
||||
/// </summary>
|
||||
/// <param name="typeListDelegate"></param>
|
||||
public void AddTypeListDelegate(Func<IEnumerable<Type>> typeListDelegate)
|
||||
{
|
||||
EnsureAddSupport();
|
||||
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
_listOfTypeListDelegates.Add(typeListDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a lazy type to the list
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void AddType(Lazy<Type> value)
|
||||
{
|
||||
EnsureAddSupport();
|
||||
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
_lazyTypeList.Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the static type added to a lazy type and adds it to the internal list
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public override void AddType(Type value)
|
||||
{
|
||||
AddType(new Lazy<Type>(() => value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all lazy types
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
EnsureClearSupport();
|
||||
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
_lazyTypeList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does not support removal
|
||||
/// </summary>
|
||||
protected override bool SupportsRemove
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does not support insert
|
||||
/// </summary>
|
||||
protected override bool SupportsInsert
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// these old classes don't contain metadata, the objects need to be instantiated first to get their metadata, we then store this
|
||||
/// for use in the GetById method.
|
||||
/// </remarks>
|
||||
internal abstract class LegacyTransientObjectsResolver<TResolver, TResolved> : ManyObjectsResolverBase<TResolver, TResolved>
|
||||
internal abstract class LegacyTransientObjectsResolver<TResolver, TResolved> : LazyManyObjectsResolverBase<TResolver, TResolved>
|
||||
where TResolved : class
|
||||
where TResolver : class
|
||||
{
|
||||
@@ -27,16 +27,15 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="refreshers"></param>
|
||||
/// <param name="types"></param>
|
||||
/// <remarks>
|
||||
/// We are creating Transient instances (new instances each time) because this is how the legacy code worked and
|
||||
/// I don't want to muck anything up by changing them to application based instances.
|
||||
/// TODO: However, it would make much more sense to do this and would speed up the application plus this would make the GetById method much easier.
|
||||
/// </remarks>
|
||||
protected LegacyTransientObjectsResolver(IEnumerable<Type> refreshers)
|
||||
: base(ObjectLifetimeScope.Transient) // new objects every time
|
||||
{
|
||||
AddTypes(refreshers);
|
||||
protected LegacyTransientObjectsResolver(Func<IEnumerable<Type>> types)
|
||||
: base(types, ObjectLifetimeScope.Transient) // new objects every time
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -55,7 +54,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
protected abstract Guid GetUniqueIdentifier(TResolved obj);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new ICacheRefresher instance by id
|
||||
/// Returns a new TResolved instance by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core.Macros;
|
||||
@@ -14,14 +15,14 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// Much of this classes methods are based on legacy code from umbraco.editorControls.macrocontainer.MacroControlFactory
|
||||
/// this code should probably be reviewed and cleaned up if necessary.
|
||||
/// </remarks>
|
||||
internal sealed class MacroFieldEditorsResolver : ManyObjectsResolverBase<MacroFieldEditorsResolver, IMacroGuiRendering>
|
||||
internal sealed class MacroFieldEditorsResolver : LazyManyObjectsResolverBase<MacroFieldEditorsResolver, IMacroGuiRendering>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="macroEditors"></param>
|
||||
internal MacroFieldEditorsResolver(IEnumerable<Type> macroEditors)
|
||||
internal MacroFieldEditorsResolver(Func<IEnumerable<Type>> macroEditors)
|
||||
: base(macroEditors, ObjectLifetimeScope.Transient)
|
||||
{
|
||||
|
||||
@@ -56,7 +57,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// </remarks>
|
||||
internal List<Type> MacroControlTypes
|
||||
{
|
||||
get { return InstanceTypes; }
|
||||
get { return InstanceTypes.ToList(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,14 +6,14 @@ using System.Web;
|
||||
|
||||
namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
|
||||
internal abstract class ManyObjectsResolverBase<TResolver, TResolved> : ResolverBase<TResolver>
|
||||
where TResolved : class
|
||||
where TResolver : class
|
||||
{
|
||||
private List<TResolved> _applicationInstances = null;
|
||||
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
|
||||
|
||||
private readonly List<Type> _instanceTypes = new List<Type>();
|
||||
|
||||
#region Constructors
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
}
|
||||
|
||||
LifetimeScope = scope;
|
||||
InstanceTypes = new List<Type>();
|
||||
_instanceTypes = new List<Type>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
if (httpContext == null) throw new ArgumentNullException("httpContext");
|
||||
LifetimeScope = ObjectLifetimeScope.HttpRequest;
|
||||
CurrentHttpContext = httpContext;
|
||||
InstanceTypes = new List<Type>();
|
||||
_instanceTypes = new List<Type>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,8 +58,8 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <param name="scope">If set to true will resolve singleton objects which will be created once for the lifetime of the application</param>
|
||||
protected ManyObjectsResolverBase(IEnumerable<Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
|
||||
: this(scope)
|
||||
{
|
||||
InstanceTypes = new List<Type>(value);
|
||||
{
|
||||
_instanceTypes = new List<Type>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
protected ManyObjectsResolverBase(HttpContextBase httpContext, IEnumerable<Type> value)
|
||||
: this(httpContext)
|
||||
{
|
||||
InstanceTypes = new List<Type>(value);
|
||||
_instanceTypes = new List<Type>(value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -83,7 +83,10 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <summary>
|
||||
/// Returns the list of Types registered that instances will be created from
|
||||
/// </summary>
|
||||
protected List<Type> InstanceTypes { get; private set; }
|
||||
protected virtual IEnumerable<Type> InstanceTypes
|
||||
{
|
||||
get { return _instanceTypes; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Current HttpContextBase used to construct this object if one exists.
|
||||
@@ -97,11 +100,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
protected ObjectLifetimeScope LifetimeScope { get; private set; }
|
||||
|
||||
private int _defaultPluginWeight = 10;
|
||||
private bool _supportsAdd = true;
|
||||
private bool _supportsInsert = true;
|
||||
private bool _supportsClear = true;
|
||||
private bool _supportsRemove = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used in conjunction with GetSortedValues and WeightedPluginAttribute, if any of the objects
|
||||
/// being resolved do not contain the WeightedPluginAttribute then this will be the default weight applied
|
||||
@@ -189,15 +188,16 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// Removes a type.
|
||||
/// </summary>
|
||||
/// <param name="value">The type to remove.</param>
|
||||
public void RemoveType(Type value)
|
||||
public virtual void RemoveType(Type value)
|
||||
{
|
||||
if (!SupportsRemove)
|
||||
throw new InvalidOperationException("This resolver does not support Removing types");
|
||||
EnsureRemoveSupport();
|
||||
|
||||
using (new WriteLock(_lock))
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
EnsureCorrectType(value);
|
||||
InstanceTypes.Remove(value);
|
||||
_instanceTypes.Remove(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,8 +215,12 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// </summary>
|
||||
/// <param name="types"></param>
|
||||
protected void AddTypes(IEnumerable<Type> types)
|
||||
{
|
||||
using (var l = new WriteLock(_lock))
|
||||
{
|
||||
EnsureAddSupport();
|
||||
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
foreach(var t in types)
|
||||
{
|
||||
@@ -225,7 +229,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
throw new InvalidOperationException("The Type " + t + " already exists in the collection");
|
||||
};
|
||||
InstanceTypes.Add(t);
|
||||
_instanceTypes.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,19 +238,20 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// Adds a Type to the end of the list.
|
||||
/// </summary>
|
||||
/// <param name="value">The object to be added.</param>
|
||||
public void AddType(Type value)
|
||||
public virtual void AddType(Type value)
|
||||
{
|
||||
if (!SupportsAdd)
|
||||
throw new InvalidOperationException("This resolver does not support Adding new types");
|
||||
EnsureAddSupport();
|
||||
|
||||
using (var l = new WriteLock(_lock))
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
EnsureCorrectType(value);
|
||||
if (InstanceTypes.Contains(value))
|
||||
{
|
||||
throw new InvalidOperationException("The Type " + value + " already exists in the collection");
|
||||
};
|
||||
InstanceTypes.Add(value);
|
||||
_instanceTypes.Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,14 +267,15 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <summary>
|
||||
/// Clears the list.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
public virtual void Clear()
|
||||
{
|
||||
if (!SupportsClear)
|
||||
throw new InvalidOperationException("This resolver does not support Clearing types");
|
||||
EnsureClearSupport();
|
||||
|
||||
using (new WriteLock(_lock))
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (GetWriteLock())
|
||||
{
|
||||
InstanceTypes.Clear();
|
||||
_instanceTypes.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,12 +284,13 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which the object should be inserted.</param>
|
||||
/// <param name="value">The object to insert.</param>
|
||||
public void InsertType(int index, Type value)
|
||||
public virtual void InsertType(int index, Type value)
|
||||
{
|
||||
if (!SupportsInsert)
|
||||
throw new InvalidOperationException("This resolver does not support Inserting new types");
|
||||
EnsureInsertSupport();
|
||||
|
||||
using (var l = new UpgradeableReadLock(_lock))
|
||||
EnsureResolutionNotFrozen();
|
||||
|
||||
using (var l = GetWriteLock())
|
||||
{
|
||||
EnsureCorrectType(value);
|
||||
if (InstanceTypes.Contains(value))
|
||||
@@ -291,8 +298,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
throw new InvalidOperationException("The Type " + value + " already exists in the collection");
|
||||
};
|
||||
|
||||
l.UpgradeToWriteLock();
|
||||
InstanceTypes.Insert(index, value);
|
||||
_instanceTypes.Insert(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +312,65 @@ namespace Umbraco.Core.ObjectResolution
|
||||
InsertType(index, typeof (T));
|
||||
}
|
||||
|
||||
private void EnsureCorrectType(Type t)
|
||||
/// <summary>
|
||||
/// Returns a WriteLock to use when modifying collections
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected WriteLock GetWriteLock()
|
||||
{
|
||||
return new WriteLock(_lock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if resolution is frozen
|
||||
/// </summary>
|
||||
protected void EnsureResolutionNotFrozen()
|
||||
{
|
||||
if (Resolution.IsFrozen)
|
||||
throw new InvalidOperationException("The type list cannot be modified after resolution has been frozen");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if this does not support Remove
|
||||
/// </summary>
|
||||
protected void EnsureRemoveSupport()
|
||||
{
|
||||
if (!SupportsRemove)
|
||||
throw new InvalidOperationException("This resolver does not support Removing types");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if this does not support Clear
|
||||
/// </summary>
|
||||
protected void EnsureClearSupport()
|
||||
{
|
||||
if (!SupportsClear)
|
||||
throw new InvalidOperationException("This resolver does not support Clearing types");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if this does not support Add
|
||||
/// </summary>
|
||||
protected void EnsureAddSupport()
|
||||
{
|
||||
if (!SupportsAdd)
|
||||
throw new InvalidOperationException("This resolver does not support Adding new types");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if this does not support insert
|
||||
/// </summary>
|
||||
protected void EnsureInsertSupport()
|
||||
{
|
||||
if (!SupportsInsert)
|
||||
throw new InvalidOperationException("This resolver does not support Inserting new types");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception if the type is not of the TResolved type
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
protected void EnsureCorrectType(Type t)
|
||||
{
|
||||
if (!TypeHelper.IsTypeAssignableFrom<TResolved>(t))
|
||||
throw new InvalidOperationException("The resolver " + this.GetType() + " can only accept types of " + typeof(TResolved) + ". The Type passed in to this method is " + t);
|
||||
@@ -314,22 +378,22 @@ namespace Umbraco.Core.ObjectResolution
|
||||
|
||||
protected virtual bool SupportsAdd
|
||||
{
|
||||
get { return _supportsAdd; }
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected virtual bool SupportsInsert
|
||||
{
|
||||
get { return _supportsInsert; }
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected virtual bool SupportsClear
|
||||
{
|
||||
get { return _supportsClear; }
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected virtual bool SupportsRemove
|
||||
{
|
||||
get { return _supportsRemove; }
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,14 @@ namespace Umbraco.Core
|
||||
/// <summary>
|
||||
/// A resolver to return all IPackageAction objects
|
||||
/// </summary>
|
||||
internal sealed class PackageActionsResolver : ManyObjectsResolverBase<PackageActionsResolver, IPackageAction>
|
||||
internal sealed class PackageActionsResolver : LazyManyObjectsResolverBase<PackageActionsResolver, IPackageAction>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="packageActions"></param>
|
||||
internal PackageActionsResolver(IEnumerable<Type> packageActions)
|
||||
internal PackageActionsResolver(Func<IEnumerable<Type>> packageActions)
|
||||
: base(packageActions)
|
||||
{
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the PetaPoco database as Singleton, so the database is created once in app lifecycle.
|
||||
/// This is necessary for transactions to work properly
|
||||
/// </summary>
|
||||
public sealed class DatabaseFactory
|
||||
{
|
||||
#region Singleton
|
||||
|
||||
private static readonly Database _database = new Database(GlobalSettings.DbDsn);
|
||||
private static readonly Lazy<DatabaseFactory> lazy = new Lazy<DatabaseFactory>(() => new DatabaseFactory());
|
||||
|
||||
public static DatabaseFactory Current { get { return lazy.Value; } }
|
||||
|
||||
private DatabaseFactory()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns an instance of the PetaPoco database
|
||||
/// </summary>
|
||||
public Database Database
|
||||
{
|
||||
get { return _database; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,8 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
UpdateDate = dto.ContentVersionDto.VersionDate,
|
||||
ExpireDate = dto.ExpiresDate.HasValue ? dto.ExpiresDate.Value : (DateTime?)null,
|
||||
ReleaseDate = dto.ReleaseDate.HasValue ? dto.ReleaseDate.Value : (DateTime?)null,
|
||||
Version = dto.ContentVersionDto.VersionId
|
||||
Version = dto.ContentVersionDto.VersionId,
|
||||
PublishedState = dto.Published ? PublishedState.Published : PublishedState.Unpublished
|
||||
};
|
||||
}
|
||||
|
||||
@@ -127,9 +128,8 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
|
||||
private NodeDto BuildNodeDto(IContent entity)
|
||||
{
|
||||
//TODO: Change this once the Language property is public on IContent
|
||||
var content = entity as Content;
|
||||
var nodeName = content != null && string.IsNullOrEmpty(content.NodeName) == false ? content.NodeName : entity.Name;
|
||||
//TODO: Change this once the Language property is public on IContent
|
||||
var nodeName = entity.Name;
|
||||
|
||||
var nodeDto = new NodeDto
|
||||
{
|
||||
|
||||
@@ -8,23 +8,26 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
internal class PropertyFactory : IEntityFactory<IEnumerable<Property>, IEnumerable<PropertyDataDto>>
|
||||
{
|
||||
private readonly IContentType _contentType;
|
||||
private readonly IMediaType _mediaType;
|
||||
private readonly IContentTypeComposition _contentType;
|
||||
private readonly Guid _version;
|
||||
private readonly int _id;
|
||||
private readonly DateTime _createDate;
|
||||
private readonly DateTime _updateDate;
|
||||
|
||||
public PropertyFactory(IContentType contentType, Guid version, int id)
|
||||
public PropertyFactory(IContentTypeComposition contentType, Guid version, int id)
|
||||
{
|
||||
_contentType = contentType;
|
||||
_version = version;
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public PropertyFactory(IMediaType mediaType, Guid version, int id)
|
||||
public PropertyFactory(IContentTypeComposition contentType, Guid version, int id, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
_mediaType = mediaType;
|
||||
_contentType = contentType;
|
||||
_version = version;
|
||||
_id = id;
|
||||
_createDate = createDate;
|
||||
_updateDate = updateDate;
|
||||
}
|
||||
|
||||
#region Implementation of IEntityFactory<IContent,PropertyDataDto>
|
||||
@@ -33,16 +36,19 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
var properties = new List<Property>();
|
||||
|
||||
foreach (var dto in dtos)
|
||||
foreach (var propertyType in _contentType.CompositionPropertyTypes)
|
||||
{
|
||||
if (_contentType.CompositionPropertyTypes.Any(x => x.Id == dto.PropertyTypeId))
|
||||
{
|
||||
var propertyType = _contentType.CompositionPropertyTypes.First(x => x.Id == dto.PropertyTypeId);
|
||||
var property = propertyType.CreatePropertyFromRawValue(dto.GetValue, dto.VersionId.Value, dto.Id);
|
||||
var propertyDataDto = dtos.LastOrDefault(x => x.PropertyTypeId == propertyType.Id);
|
||||
var property = propertyDataDto == null
|
||||
? propertyType.CreatePropertyFromValue(null)
|
||||
: propertyType.CreatePropertyFromRawValue(propertyDataDto.GetValue,
|
||||
propertyDataDto.VersionId.Value,
|
||||
propertyDataDto.Id);
|
||||
|
||||
property.ResetDirtyProperties();
|
||||
properties.Add(property);
|
||||
}
|
||||
property.CreateDate = _createDate;
|
||||
property.UpdateDate = _updateDate;
|
||||
property.ResetDirtyProperties();
|
||||
properties.Add(property);
|
||||
}
|
||||
|
||||
return properties;
|
||||
@@ -97,22 +103,5 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public IEnumerable<Property> BuildMediaEntity(IEnumerable<PropertyDataDto> dtos)
|
||||
{
|
||||
var properties = new List<Property>();
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
if (_mediaType.CompositionPropertyTypes.Any(x => x.Id == dto.PropertyTypeId))
|
||||
{
|
||||
var propertyType = _mediaType.CompositionPropertyTypes.First(x => x.Id == dto.PropertyTypeId);
|
||||
var property = propertyType.CreatePropertyFromRawValue(dto.GetValue, dto.VersionId.Value, dto.Id);
|
||||
|
||||
property.ResetDirtyProperties();
|
||||
properties.Add(property);
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -8,12 +9,21 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
internal class PropertyGroupFactory : IEntityFactory<IEnumerable<PropertyGroup>, IEnumerable<PropertyTypeGroupDto>>
|
||||
{
|
||||
private readonly int _id;
|
||||
private readonly DateTime _createDate;
|
||||
private readonly DateTime _updateDate;
|
||||
|
||||
public PropertyGroupFactory(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public PropertyGroupFactory(int id, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
_id = id;
|
||||
_createDate = createDate;
|
||||
_updateDate = updateDate;
|
||||
}
|
||||
|
||||
#region Implementation of IEntityFactory<IEnumerable<PropertyGroup>,IEnumerable<TabDto>>
|
||||
|
||||
public IEnumerable<PropertyGroup> BuildEntity(IEnumerable<PropertyTypeGroupDto> dto)
|
||||
@@ -22,9 +32,21 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
foreach (var groupDto in dto)
|
||||
{
|
||||
var group = new PropertyGroup();
|
||||
group.Id = groupDto.Id;
|
||||
//Only assign an Id if the PropertyGroup belongs to this ContentType
|
||||
if (groupDto.ContentTypeNodeId == _id)
|
||||
{
|
||||
group.Id = groupDto.Id;
|
||||
|
||||
if (groupDto.ParentGroupId.HasValue)
|
||||
group.ParentId = groupDto.ParentGroupId.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
//If the PropertyGroup is inherited, we add a reference to the group as a Parent.
|
||||
group.ParentId = groupDto.Id;
|
||||
}
|
||||
|
||||
group.Name = groupDto.Text;
|
||||
group.ParentId = groupDto.ParentGroupId;
|
||||
group.SortOrder = groupDto.SortOrder;
|
||||
group.PropertyTypes = new PropertyTypeCollection();
|
||||
|
||||
@@ -32,7 +54,8 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
var typeDtos = groupDto.PropertyTypeDtos.Where(x => x.Id > 0);
|
||||
foreach (var typeDto in typeDtos)
|
||||
{
|
||||
group.PropertyTypes.Add(new PropertyType(typeDto.DataTypeDto.ControlId,
|
||||
var tempGroupDto = groupDto;
|
||||
var propertyType = new PropertyType(typeDto.DataTypeDto.ControlId,
|
||||
typeDto.DataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true))
|
||||
{
|
||||
Alias = typeDto.Alias,
|
||||
@@ -43,9 +66,14 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
HelpText = typeDto.HelpText,
|
||||
Mandatory = typeDto.Mandatory,
|
||||
SortOrder = typeDto.SortOrder,
|
||||
PropertyGroupId = groupDto.Id
|
||||
});
|
||||
|
||||
ValidationRegExp = typeDto.ValidationRegExp,
|
||||
PropertyGroupId = new Lazy<int>(() => tempGroupDto.Id),
|
||||
CreateDate = _createDate,
|
||||
UpdateDate = _updateDate
|
||||
};
|
||||
|
||||
propertyType.ResetDirtyProperties();
|
||||
group.PropertyTypes.Add(propertyType);
|
||||
}
|
||||
group.ResetDirtyProperties();
|
||||
propertyGroups.Add(group);
|
||||
@@ -67,10 +95,12 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
ContentTypeNodeId = _id,
|
||||
SortOrder = propertyGroup.SortOrder,
|
||||
Text = propertyGroup.Name,
|
||||
ParentGroupId = propertyGroup.ParentId
|
||||
Text = propertyGroup.Name
|
||||
};
|
||||
|
||||
if (propertyGroup.ParentId.HasValue)
|
||||
dto.ParentGroupId = propertyGroup.ParentId.Value;
|
||||
|
||||
if (propertyGroup.HasIdentity)
|
||||
dto.Id = propertyGroup.Id;
|
||||
|
||||
@@ -90,11 +120,18 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
HelpText = propertyType.HelpText,
|
||||
Mandatory = propertyType.Mandatory,
|
||||
Name = propertyType.Name,
|
||||
SortOrder = propertyType.SortOrder
|
||||
SortOrder = propertyType.SortOrder,
|
||||
ValidationRegExp = propertyType.ValidationRegExp
|
||||
};
|
||||
|
||||
if (tabId != default(int))
|
||||
{
|
||||
propertyTypeDto.PropertyTypeGroupId = tabId;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyTypeDto.PropertyTypeGroupId = null;
|
||||
}
|
||||
|
||||
if (propertyType.HasIdentity)
|
||||
propertyTypeDto.Id = propertyType.Id;
|
||||
|
||||
@@ -28,17 +28,22 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
|
||||
public Template BuildEntity(TemplateDto dto)
|
||||
{
|
||||
return new Template(string.Empty, dto.NodeDto.Text, dto.Alias)
|
||||
{
|
||||
CreateDate = dto.NodeDto.CreateDate,
|
||||
Id = dto.NodeId,
|
||||
Key = dto.NodeDto.UniqueId.Value,
|
||||
CreatorId = dto.NodeDto.UserId.Value,
|
||||
Level = dto.NodeDto.Level,
|
||||
ParentId = dto.NodeDto.ParentId,
|
||||
SortOrder = dto.NodeDto.SortOrder,
|
||||
NodePath = dto.NodeDto.Path
|
||||
};
|
||||
var template = new Template(string.Empty, dto.NodeDto.Text, dto.Alias)
|
||||
{
|
||||
CreateDate = dto.NodeDto.CreateDate,
|
||||
Id = dto.NodeId,
|
||||
Key = dto.NodeDto.UniqueId.Value,
|
||||
CreatorId = dto.NodeDto.UserId.Value,
|
||||
Level = dto.NodeDto.Level,
|
||||
ParentId = dto.NodeDto.ParentId,
|
||||
SortOrder = dto.NodeDto.SortOrder,
|
||||
NodePath = dto.NodeDto.Path
|
||||
};
|
||||
|
||||
if(dto.Master.HasValue)
|
||||
template.MasterTemplateId = new Lazy<int>(() => dto.Master.Value);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
public TemplateDto BuildDto(Template entity)
|
||||
@@ -50,6 +55,11 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
NodeDto = BuildNodeDto(entity)
|
||||
};
|
||||
|
||||
if (entity.MasterTemplateId != null && entity.MasterTemplateId.Value != default(int))
|
||||
{
|
||||
dto.Master = entity.MasterTemplateId.Value;
|
||||
}
|
||||
|
||||
if (entity.HasIdentity)
|
||||
{
|
||||
dto.NodeId = entity.Id;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
IsLockedOut = dto.Disabled,
|
||||
IsApproved = dto.Disabled == false,
|
||||
Email = dto.Email,
|
||||
Lanuguage = dto.UserLanguage,
|
||||
Language = dto.UserLanguage,
|
||||
DefaultToLiveEditing = dto.DefaultToLiveEditing,
|
||||
NoConsole = dto.NoConsole,
|
||||
Permissions = dto.DefaultPermissions
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
Login = entity.Username,
|
||||
NoConsole = entity.NoConsole,
|
||||
Password = entity.Password,
|
||||
UserLanguage = entity.Lanuguage,
|
||||
UserLanguage = entity.Language,
|
||||
UserName = entity.Name,
|
||||
Type = short.Parse(entity.UserType.Id.ToString()),
|
||||
DefaultPermissions = entity.Permissions
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
string columnName = columnAttribute.Name;
|
||||
|
||||
string columnMap = string.Format("{0}.{1}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
return columnMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
internal class ModelDtoMapper : IMapper
|
||||
{
|
||||
public void GetTableInfo(Type t, TableInfo ti)
|
||||
{ }
|
||||
|
||||
public bool MapPropertyToColumn(PropertyInfo pi, ref string columnName, ref bool resultColumn)
|
||||
{
|
||||
if (pi.DeclaringType == typeof(Content) || pi.DeclaringType == typeof(IContent))
|
||||
{
|
||||
switch (pi.Name)
|
||||
{
|
||||
case "Trashed":
|
||||
columnName = "[umbracoNode].[trashed]";
|
||||
return true;
|
||||
case "ParentId":
|
||||
columnName = "[umbracoNode].[parentID]";
|
||||
return true;
|
||||
case "UserId":
|
||||
columnName = "[umbracoNode].[nodeUser]";
|
||||
return true;
|
||||
case "Level":
|
||||
columnName = "[umbracoNode].[level]";
|
||||
return true;
|
||||
case "Path":
|
||||
columnName = "[umbracoNode].[path]";
|
||||
return true;
|
||||
case "SortOrder":
|
||||
columnName = "[umbracoNode].[sortOrder]";
|
||||
return true;
|
||||
case "NodeId":
|
||||
columnName = "[umbracoNode].[id]";
|
||||
return true;
|
||||
case "Published":
|
||||
columnName = "[cmsDocument].[published]";
|
||||
return true;
|
||||
case "Key":
|
||||
columnName = "[umbracoNode].[uniqueID]";
|
||||
return true;
|
||||
case "CreateDate":
|
||||
columnName = "[umbracoNode].[createDate]";
|
||||
return true;
|
||||
case "Name":
|
||||
columnName = "[umbracoNode].[text]";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(ContentType) || pi.DeclaringType == typeof(IContentType))
|
||||
{
|
||||
switch (pi.Name)
|
||||
{
|
||||
case "Alias":
|
||||
columnName = "[cmsContentType].[alias]";
|
||||
return true;
|
||||
case "Icon":
|
||||
columnName = "[cmsContentType].[icon]";
|
||||
return true;
|
||||
case "Thumbnail":
|
||||
columnName = "[cmsContentType].[thumbnail]";
|
||||
return true;
|
||||
case "Description":
|
||||
columnName = "[cmsContentType].[description]";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Func<object, object> GetFromDbConverter(PropertyInfo pi, Type sourceType)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Func<object, object> GetToDbConverter(Type sourceType)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<User, UserDto>(src => src.IsApproved, dto => dto.Disabled);
|
||||
CacheMap<User, UserDto>(src => src.NoConsole, dto => dto.NoConsole);
|
||||
CacheMap<User, UserDto>(src => src.UserType, dto => dto.Type);
|
||||
CacheMap<User, UserDto>(src => src.Lanuguage, dto => dto.UserLanguage);
|
||||
CacheMap<User, UserDto>(src => src.Language, dto => dto.UserLanguage);
|
||||
}
|
||||
|
||||
internal override string Map(string propertyName)
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
@@ -54,15 +55,39 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
{34, typeof (TaskTypeDto)},
|
||||
{35, typeof (TaskDto)},
|
||||
{36, typeof (ContentType2ContentTypeDto)},
|
||||
{
|
||||
37,
|
||||
typeof (ContentTypeAllowedContentTypeDto)
|
||||
},
|
||||
{37, typeof (ContentTypeAllowedContentTypeDto)},
|
||||
{38, typeof (User2AppDto)},
|
||||
{39, typeof (User2NodeNotifyDto)},
|
||||
{40, typeof (User2NodePermissionDto)}
|
||||
};
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Drops all Umbraco tables in the db
|
||||
/// </summary>
|
||||
internal void UninstallDatabaseSchema()
|
||||
{
|
||||
LogHelper.Info<DatabaseSchemaCreation>("Start UninstallDatabaseSchema");
|
||||
|
||||
foreach (var item in OrderedTables.OrderByDescending(x => x.Key))
|
||||
{
|
||||
var tableNameAttribute = item.Value.FirstAttribute<TableNameAttribute>();
|
||||
|
||||
string tableName = tableNameAttribute == null ? item.Value.Name : tableNameAttribute.Value;
|
||||
|
||||
LogHelper.Info<DatabaseSchemaCreation>("Uninstall" + tableName);
|
||||
|
||||
try
|
||||
{
|
||||
_database.DropTable(tableName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//swallow this for now, not sure how best to handle this with diff databases... though this is internal
|
||||
// and only used for unit tests. If this fails its because the table doesn't exist... generally!
|
||||
LogHelper.Error<DatabaseSchemaCreation>("Could not drop table " + tableName, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseSchemaCreation(Database database)
|
||||
{
|
||||
@@ -102,7 +127,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
}
|
||||
|
||||
//Check tables in configured database against tables in schema
|
||||
var tablesInDatabase = SyntaxConfig.SqlSyntaxProvider.GetTablesInSchema(_database).ToList();
|
||||
var tablesInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetTablesInSchema(_database).ToList();
|
||||
var tablesInSchema = result.TableDefinitions.Select(x => x.Name).ToList();
|
||||
//Add valid and invalid table differences to the result object
|
||||
var validTableDifferences = tablesInDatabase.Intersect(tablesInSchema);
|
||||
@@ -117,7 +142,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
}
|
||||
|
||||
//Check columns in configured database against columns in schema
|
||||
var columnsInDatabase = SyntaxConfig.SqlSyntaxProvider.GetColumnsInSchema(_database);
|
||||
var columnsInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetColumnsInSchema(_database);
|
||||
var columnsPerTableInDatabase = columnsInDatabase.Select(x => string.Concat(x.TableName, ",", x.ColumnName)).ToList();
|
||||
var columnsPerTableInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => string.Concat(y.TableName, ",", y.Name))).ToList();
|
||||
//Add valid and invalid column differences to the result object
|
||||
@@ -134,11 +159,11 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
//MySql doesn't conform to the "normal" naming of constraints, so there is currently no point in doing these checks.
|
||||
//NOTE: At a later point we do other checks for MySql, but ideally it should be necessary to do special checks for different providers.
|
||||
if (SyntaxConfig.SqlSyntaxProvider is MySqlSyntaxProvider)
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider is MySqlSyntaxProvider)
|
||||
return result;
|
||||
|
||||
//Check constraints in configured database against constraints in schema
|
||||
var constraintsInDatabase = SyntaxConfig.SqlSyntaxProvider.GetConstraintsPerColumn(_database).DistinctBy(x => x.Item3).ToList();
|
||||
var constraintsInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetConstraintsPerColumn(_database).DistinctBy(x => x.Item3).ToList();
|
||||
var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.StartsWith("FK_")).Select(x => x.Item3).ToList();
|
||||
var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.StartsWith("PK_")).Select(x => x.Item3).ToList();
|
||||
var indexesInDatabase = constraintsInDatabase.Where(x => x.Item3.StartsWith("IX_")).Select(x => x.Item3).ToList();
|
||||
|
||||
@@ -42,8 +42,10 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
if(ValidTables.Count == 0)
|
||||
return new Version(0, 0, 0);
|
||||
|
||||
//If Errors is empty then we're at current version
|
||||
if (Errors.Any() == false)
|
||||
//If Errors is empty or if TableDefinitions tables + columns correspond to valid tables + columns then we're at current version
|
||||
if (Errors.Any() == false ||
|
||||
TableDefinitions.Any(x => ValidTables.Contains(x.Name) == false) == false &&
|
||||
TableDefinitions.SelectMany(definition => definition.Columns).Any(x => ValidColumns.Contains(x.Name) == false) == false)
|
||||
return UmbracoVersion.Current;
|
||||
|
||||
//If Errors contains umbracoApp or umbracoAppTree its pre-6.0.0 -> new Version(4, 10, 0);
|
||||
@@ -64,7 +66,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
return new Version(4, 9, 0);
|
||||
}
|
||||
|
||||
return new Version(0, 0, 0);
|
||||
return UmbracoVersion.Current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -109,7 +111,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
sb.AppendLine(" ");
|
||||
}
|
||||
|
||||
if (SyntaxConfig.SqlSyntaxProvider is MySqlSyntaxProvider)
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider is MySqlSyntaxProvider)
|
||||
{
|
||||
sb.AppendLine("Please note that the constraints could not be validated because the current dataprovider is MySql.");
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
migrationAttribute.TargetVersion > _configuredVersion &&
|
||||
migrationAttribute.TargetVersion <= _targetVersion &&
|
||||
migrationAttribute.ProductName == _productName
|
||||
orderby migrationAttribute.SortOrder ascending
|
||||
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder ascending
|
||||
select migration);
|
||||
return migrations;
|
||||
}
|
||||
@@ -119,7 +119,8 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
migrationAttribute.TargetVersion > _configuredVersion &&
|
||||
migrationAttribute.TargetVersion <= _targetVersion &&
|
||||
migrationAttribute.ProductName == _productName
|
||||
orderby migrationAttribute.SortOrder descending
|
||||
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder descending
|
||||
|
||||
select migration);
|
||||
return migrations;
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,9 +21,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Alter.Expressions
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.AlterColumn,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(Column.Name));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.AlterColumn,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(Column.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -22,9 +22,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Alter.Expressions
|
||||
{
|
||||
//NOTE Should probably investigate if Deleting a Default Constraint is different from deleting a 'regular' constraint
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteConstraint,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedName(ConstraintName));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteConstraint,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedName(ConstraintName));
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Expressions
|
||||
{
|
||||
var constraintType = (Constraint.IsPrimaryKeyConstraint) ? "PRIMARY KEY" : "UNIQUE";
|
||||
|
||||
if (Constraint.IsPrimaryKeyConstraint && SyntaxConfig.SqlSyntaxProvider.SupportsClustered())
|
||||
if (Constraint.IsPrimaryKeyConstraint && SqlSyntaxContext.SqlSyntaxProvider.SupportsClustered())
|
||||
constraintType += " CLUSTERED";
|
||||
|
||||
if (Constraint.IsNonUniqueConstraint)
|
||||
@@ -27,12 +27,12 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Expressions
|
||||
|
||||
for (int i = 0; i < Constraint.Columns.Count; i++)
|
||||
{
|
||||
columns[i] = SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(Constraint.Columns.ElementAt(i));
|
||||
columns[i] = SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(Constraint.Columns.ElementAt(i));
|
||||
}
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.CreateConstraint,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(Constraint.TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedName(Constraint.ConstraintName),
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.CreateConstraint,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(Constraint.TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedName(Constraint.ConstraintName),
|
||||
constraintType,
|
||||
string.Join(", ", columns));
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Create.Expressions
|
||||
{
|
||||
var table = new TableDefinition{Name = TableName, SchemaName = SchemaName, Columns = Columns};
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.Format(table));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.Format(table));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -31,9 +31,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
foreach (string columnName in ColumnNames)
|
||||
{
|
||||
if (ColumnNames.First() != columnName) sb.AppendLine(";");
|
||||
sb.AppendFormat(SyntaxConfig.SqlSyntaxProvider.DropColumn,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
sb.AppendFormat(SqlSyntaxContext.SqlSyntaxProvider.DropColumn,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteConstraint,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(Constraint.TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedName(Constraint.ConstraintName));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteConstraint,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(Constraint.TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedName(Constraint.ConstraintName));
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -32,7 +32,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
|
||||
if (IsAllRows)
|
||||
{
|
||||
deleteItems.Add(string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteData, SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName), "1 = 1"));
|
||||
deleteItems.Add(string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteData, SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName), "1 = 1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -42,13 +42,13 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
foreach (KeyValuePair<string, object> item in row)
|
||||
{
|
||||
whereClauses.Add(string.Format("{0} {1} {2}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(item.Key),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(item.Key),
|
||||
item.Value == null ? "IS" : "=",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedValue(item.Value.ToString())));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedValue(item.Value.ToString())));
|
||||
}
|
||||
|
||||
deleteItems.Add(string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteData,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
deleteItems.Add(string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteData,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
String.Join(" AND ", whereClauses.ToArray())));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
if (IsExpressionSupported() == false)
|
||||
return string.Empty;
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteDefaultConstraint,
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteDefaultConstraint,
|
||||
TableName,
|
||||
ColumnName);
|
||||
}
|
||||
|
||||
+6
-6
@@ -33,10 +33,10 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
if (string.IsNullOrEmpty(ForeignKey.Name))
|
||||
ForeignKey.Name = string.Format("{0}_ibfk_1", ForeignKey.ForeignTable.ToLower());
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteConstraint,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(ForeignKey.ForeignTable),
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteConstraint,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(ForeignKey.ForeignTable),
|
||||
"FOREIGN KEY ",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedName(ForeignKey.Name));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedName(ForeignKey.Name));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ForeignKey.Name))
|
||||
@@ -44,9 +44,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
ForeignKey.Name = string.Format("FK_{0}_{1}", ForeignKey.ForeignTable, ForeignKey.PrimaryTable);
|
||||
}
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DeleteConstraint,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(ForeignKey.ForeignTable),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedName(ForeignKey.Name));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteConstraint,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(ForeignKey.ForeignTable),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedName(ForeignKey.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -19,9 +19,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DropIndex,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedName(Index.Name),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(Index.TableName));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DropIndex,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedName(Index.Name),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(Index.TableName));
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,8 +17,8 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.DropTable,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DropTable,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Execute.Expressions;
|
||||
using System;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Execute.Expressions;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Syntax.Execute
|
||||
{
|
||||
@@ -21,5 +22,14 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Execute
|
||||
_databaseProviders) {SqlStatement = sqlStatement};
|
||||
_context.Expressions.Add(expression);
|
||||
}
|
||||
|
||||
public void Code(Func<Database, string> codeStatement)
|
||||
{
|
||||
var expression = _databaseProviders == null
|
||||
? new ExecuteCodeStatementExpression { CodeStatement = codeStatement }
|
||||
: new ExecuteCodeStatementExpression(_context.CurrentDatabaseProvider,
|
||||
_databaseProviders) { CodeStatement = codeStatement };
|
||||
_context.Expressions.Add(expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Syntax.Execute.Expressions
|
||||
{
|
||||
public class ExecuteCodeStatementExpression : MigrationExpressionBase
|
||||
{
|
||||
public ExecuteCodeStatementExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public ExecuteCodeStatementExpression(DatabaseProviders current, DatabaseProviders[] databaseProviders)
|
||||
: base(current, databaseProviders)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual Func<Database, string> CodeStatement { get; set; }
|
||||
|
||||
public override string Process(Database database)
|
||||
{
|
||||
if(CodeStatement != null)
|
||||
return CodeStatement(database);
|
||||
|
||||
return base.Process(database);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
namespace Umbraco.Core.Persistence.Migrations.Syntax.Execute
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Syntax.Execute
|
||||
{
|
||||
public interface IExecuteBuilder : IFluentSyntax
|
||||
{
|
||||
void Sql(string sqlStatement);
|
||||
void Code(Func<Database, string> codeStatement);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -28,9 +28,9 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Expressions
|
||||
if (string.IsNullOrEmpty(Column.TableName))
|
||||
Column.TableName = TableName;
|
||||
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.AddColumn,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(Column.TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.Format(Column));
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.AddColumn,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(Column.TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.Format(Column));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Expressions
|
||||
if (IsExpressionSupported() == false)
|
||||
return string.Empty;
|
||||
|
||||
return SyntaxConfig.SqlSyntaxProvider.Format(ForeignKey);
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.Format(ForeignKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Expressions
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return SyntaxConfig.SqlSyntaxProvider.Format(Index);
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.Format(Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -52,7 +52,7 @@ SELECT CONCAT(
|
||||
if (IsExpressionSupported() == false)
|
||||
return string.Empty;
|
||||
|
||||
return SyntaxConfig.SqlSyntaxProvider.FormatColumnRename(TableName, OldName, NewName);
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.FormatColumnRename(TableName, OldName, NewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Rename.Expressions
|
||||
if (IsExpressionSupported() == false)
|
||||
return string.Empty;
|
||||
|
||||
return SyntaxConfig.SqlSyntaxProvider.FormatTableRename(OldName, NewName);
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.FormatTableRename(OldName, NewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -31,8 +31,8 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Update.Expressions
|
||||
foreach (var item in Set)
|
||||
{
|
||||
updateItems.Add(string.Format("{0} = {1}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(item.Key),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedValue(item.Value.ToString())));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(item.Key),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedValue(item.Value.ToString())));
|
||||
}
|
||||
|
||||
if (IsAllRows)
|
||||
@@ -44,13 +44,13 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Update.Expressions
|
||||
foreach (var item in Where)
|
||||
{
|
||||
whereClauses.Add(string.Format("{0} {1} {2}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(item.Key),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(item.Key),
|
||||
item.Value == null ? "IS" : "=",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedValue(item.Value.ToString())));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedValue(item.Value.ToString())));
|
||||
}
|
||||
}
|
||||
return string.Format(SyntaxConfig.SqlSyntaxProvider.UpdateData,
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.UpdateData,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName),
|
||||
string.Join(", ", updateItems.ToArray()),
|
||||
string.Join(" AND ", whereClauses.ToArray()));
|
||||
}
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixZeroOne
|
||||
{
|
||||
[Migration("6.0.2", 0, GlobalSettings.UmbracoMigrationName)]
|
||||
public class UpdatePropertyTypesAndGroups : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
Execute.Code(UpdatePropertyTypesAndGroupsDo);
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static string UpdatePropertyTypesAndGroupsDo(Database database)
|
||||
{
|
||||
if (database != null)
|
||||
{
|
||||
//Fetch all PropertyTypes that belongs to a PropertyTypeGroup
|
||||
var propertyTypes = database.Fetch<PropertyTypeDto>("WHERE propertyTypeGroupId > 0");
|
||||
var propertyGroups = database.Fetch<PropertyTypeGroupDto>("WHERE id > 0");
|
||||
|
||||
foreach (var propertyType in propertyTypes)
|
||||
{
|
||||
//Get the PropertyTypeGroup that the current PropertyType references
|
||||
var parentPropertyTypeGroup = propertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyTypeGroupId);
|
||||
if (parentPropertyTypeGroup != null)
|
||||
{
|
||||
//If the ContentType is the same on the PropertyType and the PropertyTypeGroup the group is valid and we skip to the next
|
||||
if (parentPropertyTypeGroup.ContentTypeNodeId == propertyType.ContentTypeId) continue;
|
||||
|
||||
//Check if the 'new' PropertyTypeGroup has already been created
|
||||
var existingPropertyTypeGroup =
|
||||
propertyGroups.FirstOrDefault(
|
||||
x =>
|
||||
x.ParentGroupId == parentPropertyTypeGroup.Id && x.Text == parentPropertyTypeGroup.Text &&
|
||||
x.ContentTypeNodeId == propertyType.ContentTypeId);
|
||||
|
||||
//This should ensure that we don't create duplicate groups for a single ContentType
|
||||
if (existingPropertyTypeGroup == null)
|
||||
{
|
||||
|
||||
//Create a new PropertyTypeGroup that references the parent group that the PropertyType was referencing pre-6.0.1
|
||||
var propertyGroup = new PropertyTypeGroupDto
|
||||
{
|
||||
ContentTypeNodeId = propertyType.ContentTypeId,
|
||||
ParentGroupId = parentPropertyTypeGroup.Id,
|
||||
Text = parentPropertyTypeGroup.Text,
|
||||
SortOrder = parentPropertyTypeGroup.SortOrder
|
||||
};
|
||||
|
||||
//Save the PropertyTypeGroup in the database and update the list of groups with this new group
|
||||
int id = Convert.ToInt16(database.Insert(propertyGroup));
|
||||
propertyGroup.Id = id;
|
||||
propertyGroups.Add(propertyGroup);
|
||||
//Update the reference to the new PropertyTypeGroup on the current PropertyType
|
||||
propertyType.PropertyTypeGroupId = id;
|
||||
database.Update(propertyType);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Update the reference to the existing PropertyTypeGroup on the current PropertyType
|
||||
propertyType.PropertyTypeGroupId = existingPropertyTypeGroup.Id;
|
||||
database.Update(propertyType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,10 @@ namespace Umbraco.Core.Persistence
|
||||
var tableDefinition = DefinitionFactory.GetTableDefinition(modelType);
|
||||
var tableName = tableDefinition.Name;
|
||||
|
||||
string createSql = SyntaxConfig.SqlSyntaxProvider.Format(tableDefinition);
|
||||
string createPrimaryKeySql = SyntaxConfig.SqlSyntaxProvider.FormatPrimaryKey(tableDefinition);
|
||||
var foreignSql = SyntaxConfig.SqlSyntaxProvider.Format(tableDefinition.ForeignKeys);
|
||||
var indexSql = SyntaxConfig.SqlSyntaxProvider.Format(tableDefinition.Indexes);
|
||||
string createSql = SqlSyntaxContext.SqlSyntaxProvider.Format(tableDefinition);
|
||||
string createPrimaryKeySql = SqlSyntaxContext.SqlSyntaxProvider.FormatPrimaryKey(tableDefinition);
|
||||
var foreignSql = SqlSyntaxContext.SqlSyntaxProvider.Format(tableDefinition.ForeignKeys);
|
||||
var indexSql = SqlSyntaxContext.SqlSyntaxProvider.Format(tableDefinition.Indexes);
|
||||
|
||||
var tableExist = db.TableExist(tableName);
|
||||
if (overwrite && tableExist)
|
||||
@@ -65,18 +65,18 @@ namespace Umbraco.Core.Persistence
|
||||
var e = new TableCreationEventArgs();
|
||||
|
||||
//Turn on identity insert if db provider is not mysql
|
||||
if (SyntaxConfig.SqlSyntaxProvider.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
|
||||
db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName))));
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
|
||||
db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName))));
|
||||
|
||||
//Call the NewTable-event to trigger the insert of base/default data
|
||||
NewTable(tableName, db, e);
|
||||
|
||||
//Turn off identity insert if db provider is not mysql
|
||||
if (SyntaxConfig.SqlSyntaxProvider.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
|
||||
db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName))));
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
|
||||
db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName))));
|
||||
|
||||
//Special case for MySql
|
||||
if (SyntaxConfig.SqlSyntaxProvider is MySqlSyntaxProvider && tableName.Equals("umbracoUser"))
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider is MySqlSyntaxProvider && tableName.Equals("umbracoUser"))
|
||||
{
|
||||
db.Update<UserDto>("SET id = @IdAfter WHERE id = @IdBefore AND userLogin = @Login", new { IdAfter = 0, IdBefore = 1, Login = "admin" });
|
||||
}
|
||||
@@ -120,22 +120,40 @@ namespace Umbraco.Core.Persistence
|
||||
|
||||
public static void DropTable(this Database db, string tableName)
|
||||
{
|
||||
var sql = new Sql(string.Format("DROP TABLE {0}", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName)));
|
||||
var sql = new Sql(string.Format(
|
||||
SqlSyntaxContext.SqlSyntaxProvider.DropTable,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName)));
|
||||
db.Execute(sql);
|
||||
}
|
||||
|
||||
public static void TruncateTable(this Database db, string tableName)
|
||||
{
|
||||
var sql = new Sql(string.Format(
|
||||
SqlSyntaxContext.SqlSyntaxProvider.TruncateTable,
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName)));
|
||||
db.Execute(sql);
|
||||
}
|
||||
|
||||
public static bool TableExist(this Database db, string tableName)
|
||||
{
|
||||
return SyntaxConfig.SqlSyntaxProvider.DoesTableExist(db, tableName);
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.DoesTableExist(db, tableName);
|
||||
}
|
||||
|
||||
public static bool TableExist(this UmbracoDatabase db, string tableName)
|
||||
{
|
||||
return SyntaxConfig.SqlSyntaxProvider.DoesTableExist(db, tableName);
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.DoesTableExist(db, tableName);
|
||||
}
|
||||
|
||||
public static void CreateDatabaseSchema(this Database db)
|
||||
{
|
||||
CreateDatabaseSchema(db, true);
|
||||
}
|
||||
|
||||
internal static void CreateDatabaseSchema(this Database db, bool guardConfiguration)
|
||||
{
|
||||
if (guardConfiguration && ApplicationContext.Current.IsConfigured)
|
||||
throw new Exception("Umbraco is already configured!");
|
||||
|
||||
NewTable += PetaPocoExtensions_NewTable;
|
||||
|
||||
LogHelper.Info<Database>("Initializing database schema creation");
|
||||
@@ -143,6 +161,8 @@ namespace Umbraco.Core.Persistence
|
||||
var creation = new DatabaseSchemaCreation(db);
|
||||
creation.InitializeDatabaseSchema();
|
||||
|
||||
LogHelper.Info<Database>("Finalized database schema creation");
|
||||
|
||||
NewTable -= PetaPocoExtensions_NewTable;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Persistence
|
||||
var tableNameAttribute = type.FirstAttribute<TableNameAttribute>();
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
return sql.From(SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
return sql.From(SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
}
|
||||
|
||||
public static Sql Where<T>(this Sql sql, Expression<Func<T, bool>> predicate)
|
||||
@@ -38,8 +38,8 @@ namespace Umbraco.Core.Persistence
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
var syntax = string.Format("{0}.{1}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
|
||||
return sql.OrderBy(syntax);
|
||||
}
|
||||
@@ -54,8 +54,8 @@ namespace Umbraco.Core.Persistence
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
var syntax = string.Format("{0}.{1} DESC",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
|
||||
return sql.OrderBy(syntax);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace Umbraco.Core.Persistence
|
||||
var column = ExpressionHelper.FindProperty(columnMember) as PropertyInfo;
|
||||
var columnName = column.FirstAttribute<ColumnAttribute>().Name;
|
||||
|
||||
return sql.GroupBy(SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
return sql.GroupBy(SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
}
|
||||
|
||||
public static Sql.SqlJoinClause InnerJoin<T>(this Sql sql)
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Core.Persistence
|
||||
var tableNameAttribute = type.FirstAttribute<TableNameAttribute>();
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
return sql.InnerJoin(SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
return sql.InnerJoin(SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
}
|
||||
|
||||
public static Sql.SqlJoinClause LeftJoin<T>(this Sql sql)
|
||||
@@ -83,7 +83,7 @@ namespace Umbraco.Core.Persistence
|
||||
var tableNameAttribute = type.FirstAttribute<TableNameAttribute>();
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
return sql.LeftJoin(SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
return sql.LeftJoin(SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
}
|
||||
|
||||
public static Sql.SqlJoinClause LeftOuterJoin<T>(this Sql sql)
|
||||
@@ -92,7 +92,7 @@ namespace Umbraco.Core.Persistence
|
||||
var tableNameAttribute = type.FirstAttribute<TableNameAttribute>();
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
return sql.LeftOuterJoin(SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
return sql.LeftOuterJoin(SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
}
|
||||
|
||||
public static Sql.SqlJoinClause RightJoin<T>(this Sql sql)
|
||||
@@ -101,7 +101,7 @@ namespace Umbraco.Core.Persistence
|
||||
var tableNameAttribute = type.FirstAttribute<TableNameAttribute>();
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
return sql.RightJoin(SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
return sql.RightJoin(SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName));
|
||||
}
|
||||
|
||||
public static Sql On<TLeft, TRight>(this Sql.SqlJoinClause sql, Expression<Func<TLeft, object>> leftMember,
|
||||
@@ -118,10 +118,10 @@ namespace Umbraco.Core.Persistence
|
||||
var rightColumnName = right.FirstAttribute<ColumnAttribute>().Name;
|
||||
|
||||
string onClause = string.Format("{0}.{1} = {2}.{3}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(leftTableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(leftColumnName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(rightTableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(rightColumnName));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(leftTableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(leftColumnName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(rightTableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(rightColumnName));
|
||||
return sql.On(onClause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,572 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Querying
|
||||
{
|
||||
internal class ExpressionHelper<T>
|
||||
{
|
||||
private string selectExpression = string.Empty;
|
||||
private string whereExpression;
|
||||
private string groupBy = string.Empty;
|
||||
private string havingExpression;
|
||||
private string orderBy = string.Empty;
|
||||
|
||||
IList<string> updateFields = new List<string>();
|
||||
IList<string> insertFields = new List<string>();
|
||||
|
||||
private string sep = string.Empty;
|
||||
private bool useFieldName = false;
|
||||
private Database.PocoData pd;
|
||||
|
||||
public ExpressionHelper()
|
||||
{
|
||||
Database.Mapper = new ModelDtoMapper();
|
||||
pd = new Database.PocoData(typeof(T));
|
||||
}
|
||||
|
||||
protected internal virtual string Visit(Expression exp)
|
||||
{
|
||||
|
||||
if (exp == null) return string.Empty;
|
||||
switch (exp.NodeType)
|
||||
{
|
||||
case ExpressionType.Lambda:
|
||||
return VisitLambda(exp as LambdaExpression);
|
||||
case ExpressionType.MemberAccess:
|
||||
return VisitMemberAccess(exp as MemberExpression);
|
||||
case ExpressionType.Constant:
|
||||
return VisitConstant(exp as ConstantExpression);
|
||||
case ExpressionType.Add:
|
||||
case ExpressionType.AddChecked:
|
||||
case ExpressionType.Subtract:
|
||||
case ExpressionType.SubtractChecked:
|
||||
case ExpressionType.Multiply:
|
||||
case ExpressionType.MultiplyChecked:
|
||||
case ExpressionType.Divide:
|
||||
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(exp as BinaryExpression) + ")";
|
||||
case ExpressionType.Negate:
|
||||
case ExpressionType.NegateChecked:
|
||||
case ExpressionType.Not:
|
||||
case ExpressionType.Convert:
|
||||
case ExpressionType.ConvertChecked:
|
||||
case ExpressionType.ArrayLength:
|
||||
case ExpressionType.Quote:
|
||||
case ExpressionType.TypeAs:
|
||||
return VisitUnary(exp as UnaryExpression);
|
||||
case ExpressionType.Parameter:
|
||||
return VisitParameter(exp as ParameterExpression);
|
||||
case ExpressionType.Call:
|
||||
return VisitMethodCall(exp as MethodCallExpression);
|
||||
case ExpressionType.New:
|
||||
return VisitNew(exp as NewExpression);
|
||||
case ExpressionType.NewArrayInit:
|
||||
case ExpressionType.NewArrayBounds:
|
||||
return VisitNewArray(exp as NewArrayExpression);
|
||||
default:
|
||||
return exp.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string VisitLambda(LambdaExpression lambda)
|
||||
{
|
||||
if (lambda.Body.NodeType == ExpressionType.MemberAccess && sep == " ")
|
||||
{
|
||||
MemberExpression m = lambda.Body as MemberExpression;
|
||||
|
||||
if (m.Expression != null)
|
||||
{
|
||||
string r = VisitMemberAccess(m);
|
||||
return string.Format("{0}={1}", r, GetQuotedTrueValue());
|
||||
}
|
||||
|
||||
}
|
||||
return Visit(lambda.Body);
|
||||
}
|
||||
|
||||
protected virtual string VisitBinary(BinaryExpression b)
|
||||
{
|
||||
string left, right;
|
||||
var operand = BindOperant(b.NodeType); //sep= " " ??
|
||||
if (operand == "AND" || operand == "OR")
|
||||
{
|
||||
MemberExpression m = b.Left as MemberExpression;
|
||||
if (m != null && m.Expression != null)
|
||||
{
|
||||
string r = VisitMemberAccess(m);
|
||||
left = string.Format("{0}={1}", r, GetQuotedTrueValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
left = Visit(b.Left);
|
||||
}
|
||||
m = b.Right as MemberExpression;
|
||||
if (m != null && m.Expression != null)
|
||||
{
|
||||
string r = VisitMemberAccess(m);
|
||||
right = string.Format("{0}={1}", r, GetQuotedTrueValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
right = Visit(b.Right);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
left = Visit(b.Left);
|
||||
right = Visit(b.Right);
|
||||
}
|
||||
|
||||
if (operand == "=" && right == "null") operand = "is";
|
||||
else if (operand == "<>" && right == "null") operand = "is not";
|
||||
else if (operand == "=" || operand == "<>")
|
||||
{
|
||||
if (IsTrueExpression(right)) right = GetQuotedTrueValue();
|
||||
else if (IsFalseExpression(right)) right = GetQuotedFalseValue();
|
||||
|
||||
if (IsTrueExpression(left)) left = GetQuotedTrueValue();
|
||||
else if (IsFalseExpression(left)) left = GetQuotedFalseValue();
|
||||
|
||||
}
|
||||
|
||||
switch (operand)
|
||||
{
|
||||
case "MOD":
|
||||
case "COALESCE":
|
||||
return string.Format("{0}({1},{2})", operand, left, right);
|
||||
default:
|
||||
return left + sep + operand + sep + right;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string VisitMemberAccess(MemberExpression m)
|
||||
{
|
||||
if (m.Expression != null &&
|
||||
m.Expression.NodeType == ExpressionType.Parameter
|
||||
&& m.Expression.Type == typeof(T))
|
||||
{
|
||||
string field = GetFieldName(pd, m.Member.Name);
|
||||
return field;
|
||||
}
|
||||
|
||||
if (m.Expression != null && m.Expression.NodeType != ExpressionType.Constant)
|
||||
{
|
||||
Database.Mapper = new ModelDtoMapper();
|
||||
var def = new Database.PocoData(m.Expression.Type);
|
||||
string field = GetFieldName(def, m.Member.Name);
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
var member = Expression.Convert(m, typeof(object));
|
||||
var lambda = Expression.Lambda<Func<object>>(member);
|
||||
var getter = lambda.Compile();
|
||||
object o = getter();
|
||||
return GetQuotedValue(o, o != null ? o.GetType() : null);
|
||||
|
||||
}
|
||||
|
||||
protected virtual string VisitNew(NewExpression nex)
|
||||
{
|
||||
// TODO : check !
|
||||
var member = Expression.Convert(nex, typeof(object));
|
||||
var lambda = Expression.Lambda<Func<object>>(member);
|
||||
try
|
||||
{
|
||||
var getter = lambda.Compile();
|
||||
object o = getter();
|
||||
return GetQuotedValue(o, o.GetType());
|
||||
}
|
||||
catch (System.InvalidOperationException)
|
||||
{ // FieldName ?
|
||||
List<Object> exprs = VisitExpressionList(nex.Arguments);
|
||||
var r = new StringBuilder();
|
||||
foreach (Object e in exprs)
|
||||
{
|
||||
r.AppendFormat("{0}{1}",
|
||||
r.Length > 0 ? "," : "",
|
||||
e);
|
||||
}
|
||||
return r.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected virtual string VisitParameter(ParameterExpression p)
|
||||
{
|
||||
return p.Name;
|
||||
}
|
||||
|
||||
protected virtual string VisitConstant(ConstantExpression c)
|
||||
{
|
||||
if (c.Value == null)
|
||||
return "null";
|
||||
else if (c.Value.GetType() == typeof(bool))
|
||||
{
|
||||
object o = GetQuotedValue(c.Value, c.Value.GetType());
|
||||
return string.Format("({0}={1})", GetQuotedTrueValue(), o);
|
||||
}
|
||||
else
|
||||
return GetQuotedValue(c.Value, c.Value.GetType());
|
||||
}
|
||||
|
||||
protected virtual string VisitUnary(UnaryExpression u)
|
||||
{
|
||||
switch (u.NodeType)
|
||||
{
|
||||
case ExpressionType.Not:
|
||||
string o = Visit(u.Operand);
|
||||
if (IsFieldName(o)) o = o + "=" + GetQuotedValue(true, typeof(bool));
|
||||
return "NOT (" + o + ")";
|
||||
default:
|
||||
return Visit(u.Operand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected virtual string VisitMethodCall(MethodCallExpression m)
|
||||
{
|
||||
List<Object> args = this.VisitExpressionList(m.Arguments);
|
||||
|
||||
Object r;
|
||||
if (m.Object != null)
|
||||
r = Visit(m.Object);
|
||||
else
|
||||
{
|
||||
r = args[0];
|
||||
args.RemoveAt(0);
|
||||
}
|
||||
|
||||
switch (m.Method.Name)
|
||||
{
|
||||
case "ToUpper":
|
||||
return string.Format("upper({0})", r);
|
||||
case "ToLower":
|
||||
return string.Format("lower({0})", r);
|
||||
case "StartsWith":
|
||||
return string.Format("upper({0}) starting with {1} ", r, args[0].ToString().ToUpper());
|
||||
case "EndsWith":
|
||||
return string.Format("upper({0}) like '%{1}'", r, RemoveQuote(args[0].ToString()).ToUpper());
|
||||
case "Contains":
|
||||
return string.Format("upper({0}) like '%{1}%'", r, RemoveQuote(args[0].ToString()).ToUpper());
|
||||
case "Substring":
|
||||
var startIndex = Int32.Parse(args[0].ToString()) + 1;
|
||||
if (args.Count == 2)
|
||||
{
|
||||
var length = Int32.Parse(args[1].ToString());
|
||||
return string.Format("substring({0} from {1} for {2})",
|
||||
r,
|
||||
startIndex,
|
||||
length);
|
||||
}
|
||||
else
|
||||
return string.Format("substring({0} from {1})",
|
||||
r,
|
||||
startIndex);
|
||||
case "Round":
|
||||
case "Floor":
|
||||
case "Ceiling":
|
||||
case "Coalesce":
|
||||
case "Abs":
|
||||
case "Sum":
|
||||
return string.Format("{0}({1}{2})",
|
||||
m.Method.Name,
|
||||
r,
|
||||
args.Count == 1 ? string.Format(",{0}", args[0]) : "");
|
||||
case "Concat":
|
||||
var s = new StringBuilder();
|
||||
foreach (Object e in args)
|
||||
{
|
||||
s.AppendFormat(" || {0}", e);
|
||||
}
|
||||
return string.Format("{0}{1}", r, s.ToString());
|
||||
|
||||
case "In":
|
||||
|
||||
var member = Expression.Convert(m.Arguments[1], typeof(object));
|
||||
var lambda = Expression.Lambda<Func<object>>(member);
|
||||
var getter = lambda.Compile();
|
||||
|
||||
var inArgs = getter() as object[];
|
||||
|
||||
var sIn = new StringBuilder();
|
||||
foreach (Object e in inArgs)
|
||||
{
|
||||
if (e.GetType().ToString() != "System.Collections.Generic.List`1[System.Object]")
|
||||
{
|
||||
sIn.AppendFormat("{0}{1}",
|
||||
sIn.Length > 0 ? "," : "",
|
||||
GetQuotedValue(e, e.GetType()));
|
||||
}
|
||||
else
|
||||
{
|
||||
var listArgs = e as IList<Object>;
|
||||
foreach (Object el in listArgs)
|
||||
{
|
||||
sIn.AppendFormat("{0}{1}",
|
||||
sIn.Length > 0 ? "," : "",
|
||||
GetQuotedValue(el, el.GetType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string.Format("{0} {1} ({2})", r, m.Method.Name, sIn.ToString());
|
||||
case "Desc":
|
||||
return string.Format("{0} DESC", r);
|
||||
case "Alias":
|
||||
case "As":
|
||||
return string.Format("{0} As {1}", r,
|
||||
GetQuotedColumnName(RemoveQuoteFromAlias(RemoveQuote(args[0].ToString()))));
|
||||
case "ToString":
|
||||
return r.ToString();
|
||||
default:
|
||||
var s2 = new StringBuilder();
|
||||
foreach (Object e in args)
|
||||
{
|
||||
s2.AppendFormat(",{0}", GetQuotedValue(e, e.GetType()));
|
||||
}
|
||||
return string.Format("{0}({1}{2})", m.Method.Name, r, s2.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual List<Object> VisitExpressionList(ReadOnlyCollection<Expression> original)
|
||||
{
|
||||
var list = new List<Object>();
|
||||
for (int i = 0, n = original.Count; i < n; i++)
|
||||
{
|
||||
if (original[i].NodeType == ExpressionType.NewArrayInit ||
|
||||
original[i].NodeType == ExpressionType.NewArrayBounds)
|
||||
{
|
||||
|
||||
list.AddRange(VisitNewArrayFromExpressionList(original[i] as NewArrayExpression));
|
||||
}
|
||||
else
|
||||
list.Add(Visit(original[i]));
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected virtual string VisitNewArray(NewArrayExpression na)
|
||||
{
|
||||
|
||||
List<Object> exprs = VisitExpressionList(na.Expressions);
|
||||
var r = new StringBuilder();
|
||||
foreach (Object e in exprs)
|
||||
{
|
||||
r.Append(r.Length > 0 ? "," + e : e);
|
||||
}
|
||||
|
||||
return r.ToString();
|
||||
}
|
||||
|
||||
protected virtual List<Object> VisitNewArrayFromExpressionList(NewArrayExpression na)
|
||||
{
|
||||
|
||||
List<Object> exprs = VisitExpressionList(na.Expressions);
|
||||
return exprs;
|
||||
}
|
||||
|
||||
|
||||
protected virtual string BindOperant(ExpressionType e)
|
||||
{
|
||||
|
||||
switch (e)
|
||||
{
|
||||
case ExpressionType.Equal:
|
||||
return "=";
|
||||
case ExpressionType.NotEqual:
|
||||
return "<>";
|
||||
case ExpressionType.GreaterThan:
|
||||
return ">";
|
||||
case ExpressionType.GreaterThanOrEqual:
|
||||
return ">=";
|
||||
case ExpressionType.LessThan:
|
||||
return "<";
|
||||
case ExpressionType.LessThanOrEqual:
|
||||
return "<=";
|
||||
case ExpressionType.AndAlso:
|
||||
return "AND";
|
||||
case ExpressionType.OrElse:
|
||||
return "OR";
|
||||
case ExpressionType.Add:
|
||||
return "+";
|
||||
case ExpressionType.Subtract:
|
||||
return "-";
|
||||
case ExpressionType.Multiply:
|
||||
return "*";
|
||||
case ExpressionType.Divide:
|
||||
return "/";
|
||||
case ExpressionType.Modulo:
|
||||
return "MOD";
|
||||
case ExpressionType.Coalesce:
|
||||
return "COALESCE";
|
||||
default:
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetQuotedTableName(string tableName)
|
||||
{
|
||||
return string.Format("\"{0}\"", tableName);
|
||||
}
|
||||
|
||||
public virtual string GetQuotedColumnName(string columnName)
|
||||
{
|
||||
return string.Format("\"{0}\"", columnName);
|
||||
}
|
||||
|
||||
public virtual string GetQuotedName(string name)
|
||||
{
|
||||
return string.Format("\"{0}\"", name);
|
||||
}
|
||||
|
||||
private string GetQuotedTrueValue()
|
||||
{
|
||||
return GetQuotedValue(true, typeof(bool));
|
||||
}
|
||||
|
||||
private string GetQuotedFalseValue()
|
||||
{
|
||||
return GetQuotedValue(false, typeof(bool));
|
||||
}
|
||||
|
||||
public virtual string GetQuotedValue(object value, Type fieldType)
|
||||
{
|
||||
if (value == null) return "NULL";
|
||||
|
||||
if (!fieldType.UnderlyingSystemType.IsValueType && fieldType != typeof(string))
|
||||
{
|
||||
//if (TypeSerializer.CanCreateFromString(fieldType))
|
||||
//{
|
||||
// return "'" + EscapeParam(TypeSerializer.SerializeToString(value)) + "'";
|
||||
//}
|
||||
|
||||
throw new NotSupportedException(
|
||||
string.Format("Property of type: {0} is not supported", fieldType.FullName));
|
||||
}
|
||||
|
||||
if (fieldType == typeof(int))
|
||||
return ((int)value).ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
if (fieldType == typeof(float))
|
||||
return ((float)value).ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
if (fieldType == typeof(double))
|
||||
return ((double)value).ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
if (fieldType == typeof(decimal))
|
||||
return ((decimal)value).ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
return ShouldQuoteValue(fieldType)
|
||||
? "'" + EscapeParam(value) + "'"
|
||||
: value.ToString();
|
||||
}
|
||||
|
||||
public virtual string EscapeParam(object paramValue)
|
||||
{
|
||||
return paramValue.ToString().Replace("'", "''");
|
||||
}
|
||||
|
||||
public virtual bool ShouldQuoteValue(Type fieldType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual string GetFieldName(Database.PocoData pocoData, string name)
|
||||
{
|
||||
var column = pocoData.Columns.FirstOrDefault(x => x.Value.PropertyInfo.Name == name);
|
||||
return column.Value.ColumnName;
|
||||
}
|
||||
|
||||
protected virtual string GetFieldName(string name)
|
||||
{
|
||||
|
||||
if (useFieldName)
|
||||
{
|
||||
//FieldDefinition fd = modelDef.FieldDefinitions.FirstOrDefault(x => x.Name == name);
|
||||
//string fn = fd != default(FieldDefinition) ? fd.FieldName : name;
|
||||
//return OrmLiteConfig.DialectProvider.GetQuotedColumnName(fn);
|
||||
return "[" + name + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
protected string RemoveQuote(string exp)
|
||||
{
|
||||
|
||||
if (exp.StartsWith("'") && exp.EndsWith("'"))
|
||||
{
|
||||
exp = exp.Remove(0, 1);
|
||||
exp = exp.Remove(exp.Length - 1, 1);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
protected string RemoveQuoteFromAlias(string exp)
|
||||
{
|
||||
|
||||
if ((exp.StartsWith("\"") || exp.StartsWith("`") || exp.StartsWith("'"))
|
||||
&&
|
||||
(exp.EndsWith("\"") || exp.EndsWith("`") || exp.EndsWith("'")))
|
||||
{
|
||||
exp = exp.Remove(0, 1);
|
||||
exp = exp.Remove(exp.Length - 1, 1);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
private string GetTrueExpression()
|
||||
{
|
||||
object o = GetQuotedTrueValue();
|
||||
return string.Format("({0}={1})", o, o);
|
||||
}
|
||||
|
||||
private string GetFalseExpression()
|
||||
{
|
||||
|
||||
return string.Format("({0}={1})",
|
||||
GetQuotedTrueValue(),
|
||||
GetQuotedFalseValue());
|
||||
}
|
||||
|
||||
private bool IsTrueExpression(string exp)
|
||||
{
|
||||
return (exp == GetTrueExpression());
|
||||
}
|
||||
|
||||
private bool IsFalseExpression(string exp)
|
||||
{
|
||||
return (exp == GetFalseExpression());
|
||||
}
|
||||
|
||||
protected bool IsFieldName(string quotedExp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,7 +523,8 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
|
||||
protected bool IsFieldName(string quotedExp)
|
||||
{
|
||||
return true;
|
||||
//Not entirely sure this is reliable, but its better then simply returning true
|
||||
return quotedExp.LastIndexOf("'", StringComparison.InvariantCultureIgnoreCase) + 1 != quotedExp.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,6 +468,9 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
if(fieldType == typeof(DateTime))
|
||||
return "'" + EscapeParam(((DateTime)value).ToString(CultureInfo.InvariantCulture)) + "'";
|
||||
|
||||
if (fieldType == typeof(bool))
|
||||
return ((bool)value) ? Convert.ToString(1, CultureInfo.InvariantCulture) : Convert.ToString(0, CultureInfo.InvariantCulture);
|
||||
|
||||
return ShouldQuoteValue(fieldType)
|
||||
? "'" + EscapeParam(value) + "'"
|
||||
: value.ToString();
|
||||
@@ -487,8 +490,8 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
{
|
||||
var column = pocoData.Columns.FirstOrDefault(x => x.Value.PropertyInfo.Name == name);
|
||||
return string.Format("{0}.{1}",
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(pocoData.TableInfo.TableName),
|
||||
SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(column.Value.ColumnName));
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(pocoData.TableInfo.TableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(column.Value.ColumnName));
|
||||
}
|
||||
|
||||
protected string RemoveQuote(string exp)
|
||||
|
||||
@@ -78,7 +78,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
var sqlClause = GetBaseQuery(false);
|
||||
var translator = new SqlTranslator<IContent>(sqlClause, query);
|
||||
var sql = translator.Translate();
|
||||
var sql = translator.Translate()
|
||||
.Where<DocumentDto>(x => x.Newest)
|
||||
.OrderByDescending<ContentVersionDto>(x => x.VersionDate)
|
||||
.OrderBy<NodeDto>(x => x.SortOrder);
|
||||
|
||||
//NOTE: This doesn't allow properties to be part of the query
|
||||
var dtos = Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql);
|
||||
@@ -263,8 +266,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.Path = string.Concat(parent.Path, ",", entity.Id);
|
||||
entity.Level = parent.Level + 1;
|
||||
var maxSortOrder = Database.ExecuteScalar<int>("SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.SortOrder = maxSortOrder;
|
||||
var maxSortOrder =
|
||||
Database.ExecuteScalar<int>(
|
||||
"SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId AND nodeObjectType = @NodeObjectType",
|
||||
new {ParentId = entity.ParentId, NodeObjectType = NodeObjectTypeId});
|
||||
entity.SortOrder = maxSortOrder + 1;
|
||||
}
|
||||
|
||||
var factory = new ContentFactory(NodeObjectTypeId, entity.Id);
|
||||
@@ -368,7 +374,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
//Loop through properties to check if the content contains images/files that should be deleted
|
||||
foreach (var property in entity.Properties)
|
||||
{
|
||||
if (property.PropertyType.DataTypeId == uploadFieldId &&
|
||||
if (property.PropertyType.DataTypeId == uploadFieldId && property.Value != null &&
|
||||
string.IsNullOrEmpty(property.Value.ToString()) == false
|
||||
&& fs.FileExists(IOHelper.MapPath(property.Value.ToString())))
|
||||
{
|
||||
@@ -395,6 +401,24 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
#region Implementation of IContentRepository
|
||||
|
||||
public IEnumerable<IContent> GetByPublishedVersion(IQuery<IContent> query)
|
||||
{
|
||||
var sqlClause = GetBaseQuery(false);
|
||||
var translator = new SqlTranslator<IContent>(sqlClause, query);
|
||||
var sql = translator.Translate()
|
||||
.Where<DocumentDto>(x => x.Published)
|
||||
.OrderByDescending<ContentVersionDto>(x => x.VersionDate)
|
||||
.OrderBy<NodeDto>(x => x.SortOrder);
|
||||
|
||||
//NOTE: This doesn't allow properties to be part of the query
|
||||
var dtos = Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql);
|
||||
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
yield return CreateContentFromDto(dto, dto.VersionId);
|
||||
}
|
||||
}
|
||||
|
||||
public IContent GetByLanguage(int id, string language)
|
||||
{
|
||||
var sql = GetBaseQuery(false);
|
||||
@@ -431,13 +455,13 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
content.Template = _templateRepository.Get(dto.TemplateId.Value);
|
||||
}
|
||||
|
||||
content.Properties = GetPropertyCollection(dto.NodeId, versionId, contentType);
|
||||
content.Properties = GetPropertyCollection(dto.NodeId, versionId, contentType, content.CreateDate, content.UpdateDate);
|
||||
|
||||
((ICanBeDirty)content).ResetDirtyProperties();
|
||||
return content;
|
||||
}
|
||||
|
||||
private PropertyCollection GetPropertyCollection(int id, Guid versionId, IContentType contentType)
|
||||
private PropertyCollection GetPropertyCollection(int id, Guid versionId, IContentType contentType, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -448,8 +472,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
.Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
|
||||
var propertyDataDtos = Database.Fetch<PropertyDataDto, PropertyTypeDto>(sql);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id, createDate, updateDate);
|
||||
var properties = propertyFactory.BuildEntity(propertyDataDtos);
|
||||
|
||||
var newProperties = properties.Where(x => x.HasIdentity == false);
|
||||
foreach (var property in newProperties)
|
||||
{
|
||||
var propertyDataDto = new PropertyDataDto{ NodeId = id, PropertyTypeId = property.PropertyTypeId, VersionId = versionId };
|
||||
int primaryKey = Convert.ToInt32(Database.Insert(propertyDataDto));
|
||||
|
||||
property.Version = versionId;
|
||||
property.Id = primaryKey;
|
||||
}
|
||||
|
||||
return new PropertyCollection(properties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -40,11 +41,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
.RightJoin<PropertyTypeDto>()
|
||||
.On<PropertyTypeGroupDto, PropertyTypeDto>(left => left.Id, right => right.PropertyTypeGroupId)
|
||||
.InnerJoin<DataTypeDto>()
|
||||
.On<PropertyTypeDto, DataTypeDto>(left => left.DataTypeId, right => right.DataTypeId)
|
||||
.OrderBy<PropertyTypeDto>(x => x.PropertyTypeGroupId);
|
||||
.On<PropertyTypeDto, DataTypeDto>(left => left.DataTypeId, right => right.DataTypeId);
|
||||
|
||||
var translator = new SqlTranslator<PropertyType>(sqlClause, query);
|
||||
var sql = translator.Translate();
|
||||
var sql = translator.Translate()
|
||||
.OrderBy<PropertyTypeDto>(x => x.PropertyTypeGroupId);
|
||||
|
||||
var dtos = Database.Fetch<PropertyTypeGroupDto, PropertyTypeDto, DataTypeDto, PropertyTypeGroupDto>(new GroupPropertyTypeRelator().Map, sql);
|
||||
|
||||
@@ -107,7 +108,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
//Insert collection of allowed content types
|
||||
foreach (var allowedContentType in entity.AllowedContentTypes)
|
||||
{
|
||||
Database.Insert(new ContentTypeAllowedContentTypeDto { Id = entity.Id, AllowedId = allowedContentType.Id.Value, SortOrder = allowedContentType.SortOrder });
|
||||
Database.Insert(new ContentTypeAllowedContentTypeDto
|
||||
{
|
||||
Id = entity.Id,
|
||||
AllowedId = allowedContentType.Id.Value,
|
||||
SortOrder = allowedContentType.SortOrder
|
||||
});
|
||||
}
|
||||
|
||||
var propertyFactory = new PropertyGroupFactory(nodeDto.NodeId);
|
||||
@@ -118,103 +124,181 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var tabDto = propertyFactory.BuildGroupDto(propertyGroup);
|
||||
var primaryKey = Convert.ToInt32(Database.Insert(tabDto));
|
||||
propertyGroup.Id = primaryKey;//Set Id on PropertyGroup
|
||||
|
||||
//Ensure that the PropertyGroup's Id is set on the PropertyTypes within a group
|
||||
//unless the PropertyGroupId has already been changed.
|
||||
foreach (var propertyType in propertyGroup.PropertyTypes)
|
||||
{
|
||||
if (propertyType.IsPropertyDirty("PropertyGroupId") == false)
|
||||
{
|
||||
var tempGroup = propertyGroup;
|
||||
propertyType.PropertyGroupId = new Lazy<int>(() => tempGroup.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Insert PropertyTypes
|
||||
foreach (var propertyGroup in entity.PropertyGroups)
|
||||
foreach (var propertyType in entity.PropertyTypes)
|
||||
{
|
||||
foreach (var propertyType in propertyGroup.PropertyTypes)
|
||||
{
|
||||
var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(propertyGroup.Id, propertyType);
|
||||
var primaryKey = Convert.ToInt32(Database.Insert(propertyTypeDto));
|
||||
propertyType.Id = primaryKey;//Set Id on PropertyType
|
||||
var tabId = propertyType.PropertyGroupId != null ? propertyType.PropertyGroupId.Value : default(int);
|
||||
var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(tabId, propertyType);
|
||||
int typePrimaryKey = Convert.ToInt32(Database.Insert(propertyTypeDto));
|
||||
propertyType.Id = typePrimaryKey; //Set Id on new PropertyType
|
||||
|
||||
//Update the current PropertyType with correct ControlId and DatabaseType
|
||||
var dataTypeDto = Database.FirstOrDefault<DataTypeDto>("WHERE nodeId = @Id", new { Id = propertyTypeDto.DataTypeId });
|
||||
propertyType.DataTypeId = dataTypeDto.ControlId;
|
||||
propertyType.DataTypeDatabaseType = dataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true);
|
||||
}
|
||||
//Update the current PropertyType with correct ControlId and DatabaseType
|
||||
var dataTypeDto = Database.FirstOrDefault<DataTypeDto>("WHERE nodeId = @Id", new { Id = propertyTypeDto.DataTypeId });
|
||||
propertyType.DataTypeId = dataTypeDto.ControlId;
|
||||
propertyType.DataTypeDatabaseType = dataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void PersistUpdatedBaseContentType(ContentTypeDto dto, IContentTypeComposition entity)
|
||||
{
|
||||
var propertyFactory = new PropertyGroupFactory(entity.Id);
|
||||
var propertyGroupFactory = new PropertyGroupFactory(entity.Id);
|
||||
|
||||
var nodeDto = dto.NodeDto;
|
||||
var o = Database.Update(nodeDto);
|
||||
|
||||
//Look up ContentType entry to get PrimaryKey for updating the DTO
|
||||
var dtoPk = Database.First<ContentTypeDto>("WHERE nodeId = @Id", new { Id = entity.Id });
|
||||
var dtoPk = Database.First<ContentTypeDto>("WHERE nodeId = @Id", new {Id = entity.Id});
|
||||
dto.PrimaryKey = dtoPk.PrimaryKey;
|
||||
Database.Update(dto);
|
||||
|
||||
//Delete the ContentType composition entries before adding the updated collection
|
||||
Database.Delete<ContentType2ContentTypeDto>("WHERE childContentTypeId = @Id", new { Id = entity.Id });
|
||||
Database.Delete<ContentType2ContentTypeDto>("WHERE childContentTypeId = @Id", new {Id = entity.Id});
|
||||
//Update ContentType composition in new table
|
||||
foreach (var composition in entity.ContentTypeComposition)
|
||||
{
|
||||
Database.Insert(new ContentType2ContentTypeDto { ParentId = composition.Id, ChildId = entity.Id });
|
||||
Database.Insert(new ContentType2ContentTypeDto {ParentId = composition.Id, ChildId = entity.Id});
|
||||
}
|
||||
|
||||
//Removing a ContentType from a composition (U4-1690)
|
||||
//1. Find content based on the current ContentType: entity.Id
|
||||
//2. Find all PropertyTypes on the ContentType that was removed - tracked id (key)
|
||||
//3. Remove properties based on property types from the removed content type where the content ids correspond to those found in step one
|
||||
var compositionBase = entity as ContentTypeCompositionBase;
|
||||
if (compositionBase != null && compositionBase.RemovedContentTypeKeyTracker != null &&
|
||||
compositionBase.RemovedContentTypeKeyTracker.Any())
|
||||
{
|
||||
//Find Content based on the current ContentType
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
.From<ContentDto>()
|
||||
.InnerJoin<NodeDto>()
|
||||
.On<ContentDto, NodeDto>(left => left.NodeId, right => right.NodeId)
|
||||
.Where<NodeDto>(x => x.NodeObjectType == new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"))
|
||||
.Where<ContentDto>(x => x.ContentTypeId == entity.Id);
|
||||
|
||||
var contentDtos = Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql);
|
||||
//Loop through all tracked keys, which corresponds to the ContentTypes that has been removed from the composition
|
||||
foreach (var key in compositionBase.RemovedContentTypeKeyTracker)
|
||||
{
|
||||
//Find PropertyTypes for the removed ContentType
|
||||
var propertyTypes = Database.Fetch<PropertyTypeDto>("WHERE contentTypeId = @Id", new {Id = key});
|
||||
//Loop through the Content that is based on the current ContentType in order to remove the Properties that are
|
||||
//based on the PropertyTypes that belong to the removed ContentType.
|
||||
foreach (var contentDto in contentDtos)
|
||||
{
|
||||
foreach (var propertyType in propertyTypes)
|
||||
{
|
||||
var nodeId = contentDto.NodeId;
|
||||
var propertyTypeId = propertyType.Id;
|
||||
var propertySql = new Sql().Select("*")
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>()
|
||||
.On<PropertyDataDto, PropertyTypeDto>(
|
||||
left => left.PropertyTypeId, right => right.Id)
|
||||
.Where<PropertyDataDto>(x => x.NodeId == nodeId)
|
||||
.Where<PropertyTypeDto>(x => x.Id == propertyTypeId);
|
||||
|
||||
//Finally delete the properties that match our criteria for removing a ContentType from the composition
|
||||
Database.Delete<PropertyDataDto>(propertySql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Delete the allowed content type entries before adding the updated collection
|
||||
Database.Delete<ContentTypeAllowedContentTypeDto>("WHERE Id = @Id", new { Id = entity.Id });
|
||||
Database.Delete<ContentTypeAllowedContentTypeDto>("WHERE Id = @Id", new {Id = entity.Id});
|
||||
//Insert collection of allowed content types
|
||||
foreach (var allowedContentType in entity.AllowedContentTypes)
|
||||
{
|
||||
Database.Insert(new ContentTypeAllowedContentTypeDto { Id = entity.Id, AllowedId = allowedContentType.Id.Value, SortOrder = allowedContentType.SortOrder });
|
||||
Database.Insert(new ContentTypeAllowedContentTypeDto
|
||||
{
|
||||
Id = entity.Id,
|
||||
AllowedId = allowedContentType.Id.Value,
|
||||
SortOrder = allowedContentType.SortOrder
|
||||
});
|
||||
}
|
||||
|
||||
//Check Dirty properties for Tabs/Groups and PropertyTypes - insert and delete accordingly
|
||||
if (((ICanBeDirty)entity).IsPropertyDirty("PropertyGroups") || entity.PropertyGroups.Any(x => x.IsDirty()))
|
||||
if (((ICanBeDirty) entity).IsPropertyDirty("PropertyTypes") || entity.PropertyTypes.Any(x => x.IsDirty()))
|
||||
{
|
||||
//Delete PropertyTypes by excepting entries from db with entries from collections
|
||||
var dbPropertyTypes = Database.Fetch<PropertyTypeDto>("WHERE contentTypeId = @Id", new { Id = entity.Id });
|
||||
var dbPropertyTypeAlias = dbPropertyTypes.Select(x => x.Alias.ToLowerInvariant());
|
||||
var entityPropertyTypes = entity.PropertyTypes.Select(x => x.Alias.ToLowerInvariant());
|
||||
var aliases = dbPropertyTypeAlias.Except(entityPropertyTypes);
|
||||
foreach (var alias in aliases)
|
||||
var dbPropertyTypes = Database.Fetch<PropertyTypeDto>("WHERE contentTypeId = @Id", new {Id = entity.Id});
|
||||
var dbPropertyTypeAlias = dbPropertyTypes.Select(x => x.Id);
|
||||
var entityPropertyTypes = entity.PropertyTypes.Where(x => x.HasIdentity).Select(x => x.Id);
|
||||
var items = dbPropertyTypeAlias.Except(entityPropertyTypes);
|
||||
foreach (var item in items)
|
||||
{
|
||||
//Before a PropertyType can be deleted, all Properties based on that PropertyType should be deleted.
|
||||
var propertyType = dbPropertyTypes.FirstOrDefault(x => x.Alias.ToLowerInvariant() == alias);
|
||||
if (propertyType != null)
|
||||
{
|
||||
Database.Delete<PropertyDataDto>("WHERE propertytypeid = @Id", new { Id = propertyType.Id });
|
||||
}
|
||||
|
||||
Database.Delete<PropertyTypeDto>("WHERE contentTypeId = @Id AND Alias = @Alias", new { Id = entity.Id, Alias = alias });
|
||||
Database.Delete<PropertyDataDto>("WHERE propertytypeid = @Id", new {Id = item});
|
||||
Database.Delete<PropertyTypeDto>("WHERE contentTypeId = @Id AND id = @PropertyTypeId",
|
||||
new {Id = entity.Id, PropertyTypeId = item});
|
||||
}
|
||||
}
|
||||
|
||||
if (((ICanBeDirty) entity).IsPropertyDirty("PropertyGroups") || entity.PropertyGroups.Any(x => x.IsDirty()))
|
||||
{
|
||||
//Delete Tabs/Groups by excepting entries from db with entries from collections
|
||||
var dbPropertyGroups = Database.Fetch<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id", new { Id = entity.Id }).Select(x => x.Text);
|
||||
var entityPropertyGroups = entity.PropertyGroups.Select(x => x.Name);
|
||||
var dbPropertyGroups =
|
||||
Database.Fetch<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id", new {Id = entity.Id})
|
||||
.Select(x => new Tuple<int, string>(x.Id, x.Text));
|
||||
var entityPropertyGroups = entity.PropertyGroups.Select(x => new Tuple<int, string>(x.Id, x.Name));
|
||||
var tabs = dbPropertyGroups.Except(entityPropertyGroups);
|
||||
foreach (var tabName in tabs)
|
||||
foreach (var tab in tabs)
|
||||
{
|
||||
Database.Delete<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id AND text = @Name", new { Id = entity.Id, Name = tabName });
|
||||
Database.Update<PropertyTypeDto>("SET propertyTypeGroupId = NULL WHERE propertyTypeGroupId = @PropertyGroupId",
|
||||
new {PropertyGroupId = tab.Item1});
|
||||
Database.Update<PropertyTypeGroupDto>("SET parentGroupId = NULL WHERE parentGroupId = @TabId",
|
||||
new {TabId = tab.Item1});
|
||||
Database.Delete<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id AND text = @Name",
|
||||
new {Id = entity.Id, Name = tab.Item2});
|
||||
}
|
||||
}
|
||||
|
||||
//Run through all groups to insert or update entries
|
||||
foreach (var propertyGroup in entity.PropertyGroups)
|
||||
{
|
||||
var tabDto = propertyFactory.BuildGroupDto(propertyGroup);
|
||||
int groupPrimaryKey = propertyGroup.HasIdentity
|
||||
? Database.Update(tabDto)
|
||||
: Convert.ToInt32(Database.Insert(tabDto));
|
||||
if (!propertyGroup.HasIdentity)
|
||||
propertyGroup.Id = groupPrimaryKey;//Set Id on new PropertyGroup
|
||||
}
|
||||
//Run through all groups to insert or update entries
|
||||
foreach (var propertyGroup in entity.PropertyGroups)
|
||||
{
|
||||
var tabDto = propertyGroupFactory.BuildGroupDto(propertyGroup);
|
||||
int groupPrimaryKey = propertyGroup.HasIdentity
|
||||
? Database.Update(tabDto)
|
||||
: Convert.ToInt32(Database.Insert(tabDto));
|
||||
if (propertyGroup.HasIdentity == false)
|
||||
propertyGroup.Id = groupPrimaryKey; //Set Id on new PropertyGroup
|
||||
|
||||
//Run through all PropertyTypes to insert or update entries
|
||||
foreach (var propertyType in entity.PropertyTypes)
|
||||
//Ensure that the PropertyGroup's Id is set on the PropertyTypes within a group
|
||||
//unless the PropertyGroupId has already been changed.
|
||||
foreach (var propertyType in propertyGroup.PropertyTypes)
|
||||
{
|
||||
var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(propertyType.PropertyGroupId, propertyType);
|
||||
int typePrimaryKey = propertyType.HasIdentity
|
||||
? Database.Update(propertyTypeDto)
|
||||
: Convert.ToInt32(Database.Insert(propertyTypeDto));
|
||||
if (!propertyType.HasIdentity)
|
||||
propertyType.Id = typePrimaryKey;//Set Id on new PropertyType
|
||||
if (propertyType.IsPropertyDirty("PropertyGroupId") == false)
|
||||
{
|
||||
var tempGroup = propertyGroup;
|
||||
propertyType.PropertyGroupId = new Lazy<int>(() => tempGroup.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Run through all PropertyTypes to insert or update entries
|
||||
foreach (var propertyType in entity.PropertyTypes)
|
||||
{
|
||||
var tabId = propertyType.PropertyGroupId != null ? propertyType.PropertyGroupId.Value : default(int);
|
||||
var propertyTypeDto = propertyGroupFactory.BuildPropertyTypeDto(tabId, propertyType);
|
||||
int typePrimaryKey = propertyType.HasIdentity
|
||||
? Database.Update(propertyTypeDto)
|
||||
: Convert.ToInt32(Database.Insert(propertyTypeDto));
|
||||
if (propertyType.HasIdentity == false)
|
||||
propertyType.Id = typePrimaryKey; //Set Id on new PropertyType
|
||||
}
|
||||
}
|
||||
|
||||
protected IEnumerable<ContentTypeSort> GetAllowedContentTypeIds(int id)
|
||||
@@ -228,7 +312,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return allowedContentTypeDtos.Select(x => new ContentTypeSort { Id = new Lazy<int>(() => x.AllowedId), SortOrder = x.SortOrder }).ToList();
|
||||
}
|
||||
|
||||
protected PropertyGroupCollection GetPropertyGroupCollection(int id)
|
||||
protected PropertyGroupCollection GetPropertyGroupCollection(int id, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -242,12 +326,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
var dtos = Database.Fetch<PropertyTypeGroupDto, PropertyTypeDto, DataTypeDto, PropertyTypeGroupDto>(new GroupPropertyTypeRelator().Map, sql);
|
||||
|
||||
var propertyFactory = new PropertyGroupFactory(id);
|
||||
var propertyGroups = propertyFactory.BuildEntity(dtos);
|
||||
var propertyGroupFactory = new PropertyGroupFactory(id, createDate, updateDate);
|
||||
var propertyGroups = propertyGroupFactory.BuildEntity(dtos);
|
||||
return new PropertyGroupCollection(propertyGroups);
|
||||
}
|
||||
|
||||
protected PropertyTypeCollection GetPropertyTypeCollection(int id)
|
||||
protected PropertyTypeCollection GetPropertyTypeCollection(int id, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -272,9 +356,15 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Name = dto.Name,
|
||||
HelpText = dto.HelpText,
|
||||
Mandatory = dto.Mandatory,
|
||||
SortOrder = dto.SortOrder
|
||||
});
|
||||
|
||||
SortOrder = dto.SortOrder,
|
||||
ValidationRegExp = dto.ValidationRegExp,
|
||||
CreateDate = createDate,
|
||||
UpdateDate = updateDate
|
||||
}).ToList();
|
||||
|
||||
//Reset dirty properties
|
||||
Parallel.ForEach(list, currentFile => currentFile.ResetDirtyProperties());
|
||||
|
||||
return new PropertyTypeCollection(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -50,8 +51,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var contentType = factory.BuildEntity(dto);
|
||||
|
||||
contentType.AllowedContentTypes = GetAllowedContentTypeIds(id);
|
||||
contentType.PropertyGroups = GetPropertyGroupCollection(id);
|
||||
((ContentType)contentType).PropertyTypes = GetPropertyTypeCollection(id);
|
||||
contentType.PropertyGroups = GetPropertyGroupCollection(id, contentType.CreateDate, contentType.UpdateDate);
|
||||
((ContentType)contentType).PropertyTypes = GetPropertyTypeCollection(id, contentType.CreateDate, contentType.UpdateDate);
|
||||
|
||||
var templates = Database.Fetch<DocumentTypeDto>("WHERE contentTypeNodeId = @Id", new { Id = id });
|
||||
if(templates.Any())
|
||||
@@ -93,7 +94,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
var sqlClause = GetBaseQuery(false);
|
||||
var translator = new SqlTranslator<IContentType>(sqlClause, query);
|
||||
var sql = translator.Translate();
|
||||
var sql = translator.Translate()
|
||||
.OrderBy<NodeDto>(x => x.Text);
|
||||
|
||||
var dtos = Database.Fetch<DocumentTypeDto, ContentTypeDto, NodeDto>(sql);
|
||||
|
||||
@@ -166,6 +168,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistNewItem(IContentType entity)
|
||||
{
|
||||
Mandate.That<Exception>(string.IsNullOrEmpty(entity.Alias) == false,
|
||||
() =>
|
||||
{
|
||||
var message =
|
||||
string.Format(
|
||||
"ContentType '{0}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
|
||||
entity.Name);
|
||||
var exception = new Exception(message);
|
||||
|
||||
LogHelper.Error<ContentTypeRepository>(message, exception);
|
||||
throw exception;
|
||||
});
|
||||
|
||||
((ContentType)entity).AddingEntity();
|
||||
|
||||
var factory = new ContentTypeFactory(NodeObjectTypeId);
|
||||
@@ -191,6 +206,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistUpdatedItem(IContentType entity)
|
||||
{
|
||||
Mandate.That<Exception>(string.IsNullOrEmpty(entity.Alias) == false,
|
||||
() =>
|
||||
{
|
||||
var message =
|
||||
string.Format(
|
||||
"ContentType '{0}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
|
||||
entity.Name);
|
||||
var exception = new Exception(message);
|
||||
|
||||
LogHelper.Error<ContentTypeRepository>(message, exception);
|
||||
throw exception;
|
||||
});
|
||||
|
||||
//Updates Modified date
|
||||
((ContentType)entity).UpdatingEntity();
|
||||
|
||||
@@ -199,6 +227,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.Path = string.Concat(parent.Path, ",", entity.Id);
|
||||
entity.Level = parent.Level + 1;
|
||||
var maxSortOrder =
|
||||
Database.ExecuteScalar<int>(
|
||||
"SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId AND nodeObjectType = @NodeObjectType",
|
||||
new { ParentId = entity.ParentId, NodeObjectType = NodeObjectTypeId });
|
||||
entity.SortOrder = maxSortOrder + 1;
|
||||
}
|
||||
|
||||
var factory = new ContentTypeFactory(NodeObjectTypeId);
|
||||
|
||||
@@ -159,6 +159,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.Path = string.Concat(parent.Path, ",", entity.Id);
|
||||
entity.Level = parent.Level + 1;
|
||||
var maxSortOrder =
|
||||
Database.ExecuteScalar<int>(
|
||||
"SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId AND nodeObjectType = @NodeObjectType",
|
||||
new { ParentId = entity.ParentId, NodeObjectType = NodeObjectTypeId });
|
||||
entity.SortOrder = maxSortOrder + 1;
|
||||
}
|
||||
|
||||
var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
|
||||
|
||||
@@ -111,6 +111,20 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
#endregion
|
||||
|
||||
protected IEnumerable<string> FindAllFiles(string path)
|
||||
{
|
||||
var list = new List<string>();
|
||||
list.AddRange(FileSystem.GetFiles(path, "*"));
|
||||
|
||||
var directories = FileSystem.GetDirectories(path);
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
list.AddRange(FindAllFiles(directory));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose any disposable properties
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Umbraco.Core.Models;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
@@ -11,5 +13,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="language">Culture code for the language to retrieve</param>
|
||||
/// <returns>An <see cref="IContent"/> item</returns>
|
||||
IContent GetByLanguage(int id, string language);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all published Content byh the specified query
|
||||
/// </summary>
|
||||
/// <param name="query">Query to execute against published versions</param>
|
||||
/// <returns>An enumerable list of <see cref="IContent"/></returns>
|
||||
IEnumerable<IContent> GetByPublishedVersion(IQuery<IContent> query);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var factory = new MediaFactory(mediaType, NodeObjectTypeId, id);
|
||||
var media = factory.BuildEntity(dto);
|
||||
|
||||
media.Properties = GetPropertyCollection(id, dto.VersionId, mediaType);
|
||||
media.Properties = GetPropertyCollection(id, dto.VersionId, mediaType, media.CreateDate, media.UpdateDate);
|
||||
|
||||
((ICanBeDirty)media).ResetDirtyProperties();
|
||||
return media;
|
||||
@@ -118,6 +118,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
"DELETE FROM umbracoUser2NodeNotify WHERE nodeId = @Id",
|
||||
"DELETE FROM umbracoUser2NodePermission WHERE nodeId = @Id",
|
||||
"DELETE FROM umbracoRelation WHERE parentId = @Id",
|
||||
"DELETE FROM umbracoRelation WHERE childId = @Id",
|
||||
"DELETE FROM cmsTagRelationship WHERE nodeId = @Id",
|
||||
"DELETE FROM cmsDocument WHERE NodeId = @Id",
|
||||
"DELETE FROM cmsPropertyData WHERE contentNodeId = @Id",
|
||||
@@ -155,7 +157,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var factory = new MediaFactory(mediaType, NodeObjectTypeId, dto.NodeId);
|
||||
var media = factory.BuildEntity(dto);
|
||||
|
||||
media.Properties = GetPropertyCollection(dto.NodeId, dto.VersionId, mediaType);
|
||||
media.Properties = GetPropertyCollection(dto.NodeId, dto.VersionId, mediaType, media.CreateDate, media.UpdateDate);
|
||||
|
||||
((ICanBeDirty)media).ResetDirtyProperties();
|
||||
return media;
|
||||
@@ -246,8 +248,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.Path = string.Concat(parent.Path, ",", entity.Id);
|
||||
entity.Level = parent.Level + 1;
|
||||
var maxSortOrder = Database.ExecuteScalar<int>("SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.SortOrder = maxSortOrder;
|
||||
var maxSortOrder =
|
||||
Database.ExecuteScalar<int>(
|
||||
"SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId AND nodeObjectType = @NodeObjectType",
|
||||
new { ParentId = entity.ParentId, NodeObjectType = NodeObjectTypeId });
|
||||
entity.SortOrder = maxSortOrder + 1;
|
||||
}
|
||||
|
||||
var factory = new MediaFactory(NodeObjectTypeId, entity.Id);
|
||||
@@ -335,7 +340,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
#endregion
|
||||
|
||||
private PropertyCollection GetPropertyCollection(int id, Guid versionId, IMediaType contentType)
|
||||
private PropertyCollection GetPropertyCollection(int id, Guid versionId, IMediaType contentType, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -346,8 +351,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
.Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
|
||||
var propertyDataDtos = Database.Fetch<PropertyDataDto, PropertyTypeDto>(sql);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id);
|
||||
var properties = propertyFactory.BuildMediaEntity(propertyDataDtos);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id, createDate, updateDate);
|
||||
var properties = propertyFactory.BuildEntity(propertyDataDtos);
|
||||
|
||||
var newProperties = properties.Where(x => x.HasIdentity == false);
|
||||
foreach (var property in newProperties)
|
||||
{
|
||||
var propertyDataDto = new PropertyDataDto { NodeId = id, PropertyTypeId = property.PropertyTypeId, VersionId = versionId };
|
||||
int primaryKey = Convert.ToInt32(Database.Insert(propertyDataDto));
|
||||
|
||||
property.Version = versionId;
|
||||
property.Id = primaryKey;
|
||||
}
|
||||
|
||||
return new PropertyCollection(properties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var contentType = factory.BuildEntity(dto);
|
||||
|
||||
contentType.AllowedContentTypes = GetAllowedContentTypeIds(id);
|
||||
contentType.PropertyGroups = GetPropertyGroupCollection(id);
|
||||
((MediaType)contentType).PropertyTypes = GetPropertyTypeCollection(id);
|
||||
contentType.PropertyGroups = GetPropertyGroupCollection(id, contentType.CreateDate, contentType.UpdateDate);
|
||||
((MediaType)contentType).PropertyTypes = GetPropertyTypeCollection(id, contentType.CreateDate, contentType.UpdateDate);
|
||||
|
||||
var list = Database.Fetch<ContentType2ContentTypeDto>("WHERE childContentTypeId = @Id", new{ Id = id});
|
||||
foreach (var contentTypeDto in list)
|
||||
@@ -168,6 +168,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
|
||||
entity.Path = string.Concat(parent.Path, ",", entity.Id);
|
||||
entity.Level = parent.Level + 1;
|
||||
var maxSortOrder =
|
||||
Database.ExecuteScalar<int>(
|
||||
"SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId AND nodeObjectType = @NodeObjectType",
|
||||
new { ParentId = entity.ParentId, NodeObjectType = NodeObjectTypeId });
|
||||
entity.SortOrder = maxSortOrder + 1;
|
||||
}
|
||||
|
||||
var factory = new MediaTypeFactory(NodeObjectTypeId);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user