{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \n\n\nIf not, maybe it'll give you some ideas.\n\nA:\n\nI'm not sure if this is what you mean, but you can bind custom events and then trigger them.\nhttp://docs.jquery.com/Events/bind\nSo add your hover event, script the functionality you need for that hover, then trigger your custom event.\n\nA:\n\nMaybe it would be easier to just hide the old element and create a clone with your event handlers attached? Then just swap back in the old element when you're done..\n\n"},"title":{"kind":"string","value":"How to read bound hover callback functions in jQuery"},"question":{"kind":"string","value":"I used jQuery to set hover callbacks for elements on my page. I'm now writing a module which needs to temporarily set new hover behaviour for some elements. The new module has no access to the original code for the hover functions.\nI want to store the old hover functions before I set new ones so I can restore them when finished with the temporary hover behaviour.\nI think these can be stored using the jQuery.data() function:\n//save old hover behavior (somehow)\n\n$('#foo').data('oldhoverin',???)\n\n$('#foo').data('oldhoverout',???);\n\n//set new hover behavior\n\n$('#foo').hover(newhoverin,newhoverout);\n\nDo stuff with new hover behaviour...\n//restore old hover behaviour\n$('#foo').hover($('#foo').data('oldhoverin'),$('#foo').data('oldhoverout'));\n\nBut how do I get the currently registered hover functions from jQuery?\nShadow2531, I am trying to do this without modifying the code which originally registered the callbacks. Your suggestion would work fine otherwise. Thanks for the suggestion, and for helping clarify what I'm searching for. Maybe I have to go into the source of jquery and figure out how these callbacks are stored internally. Maybe I should change the question to \"Is it possible to do this without modifying jquery?\"\n"},"answers":{"kind":"list like","value":["Calling an event bind method (such as hover) does not delete old event handlers, only adds your new events, so your idea of 'restoring' the old event functions wouldn't work, as it wouldn't delete your events.\nYou can add your own events, and then remove them without affecting any other events then use Event namespacing: http://docs.jquery.com/Events_(Guide)#Namespacing_events\n","Not sure if this will work, but you can try this:\n\n\n\n \n \n Jquery - Get, change and restore hover handlers\n \n \n \n \n

test

\n \n\n\nIf not, maybe it'll give you some ideas.\n","I'm not sure if this is what you mean, but you can bind custom events and then trigger them.\nhttp://docs.jquery.com/Events/bind\nSo add your hover event, script the functionality you need for that hover, then trigger your custom event.\n","Maybe it would be easier to just hide the old element and create a clone with your event handlers attached? Then just swap back in the old element when you're done..\n"],"string":"[\n \"Calling an event bind method (such as hover) does not delete old event handlers, only adds your new events, so your idea of 'restoring' the old event functions wouldn't work, as it wouldn't delete your events.\\nYou can add your own events, and then remove them without affecting any other events then use Event namespacing: http://docs.jquery.com/Events_(Guide)#Namespacing_events\\n\",\n \"Not sure if this will work, but you can try this:\\n\\n\\n\\n \\n \\n Jquery - Get, change and restore hover handlers\\n \\n \\n \\n \\n

test

\\n \\n\\n\\nIf not, maybe it'll give you some ideas.\\n\",\n \"I'm not sure if this is what you mean, but you can bind custom events and then trigger them.\\nhttp://docs.jquery.com/Events/bind\\nSo add your hover event, script the functionality you need for that hover, then trigger your custom event.\\n\",\n \"Maybe it would be easier to just hide the old element and create a clone with your event handlers attached? Then just swap back in the old element when you're done..\\n\"\n]"},"answers_scores":{"kind":"list like","value":[4,1,0,0],"string":"[\n 4,\n 1,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["callback","javascript","jquery"],"string":"[\n \"callback\",\n \"javascript\",\n \"jquery\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000048931_callback_javascript_jquery.txt"}}},{"rowIdx":1576,"cells":{"content":{"kind":"string","value":"Q:\n\nHow to limit result set size for arbitrary query in Ingres?\n\nIn Oracle, the number of rows returned in an arbitrary query can be limited by filtering on the \"virtual\" rownum column. Consider the following example, which will return, at most, 10 rows.\nSELECT * FROM all_tables WHERE rownum <= 10\nIs there a simple, generic way to do something similar in Ingres?\n\nA:\n\nBlatantly changing my answer. \"Limit 10\" works for MySql and others, Ingres uses\nSelect First 10 * from myTable\n\nRef\n\nA:\n\nselect * from myTable limit 10 does not work.\nHave discovered one possible solution:\n\n TIDs are \"tuple identifiers\" or row addresses. The TID contains the\n page number and the index of the offset to the row relative to the\n page boundary. TIDs are presently implemented as 4-byte integers.\n The TID uniquely identifies each row in a table. Every row has a\n TID. The high-order 23 bits of the TID are the page number of the page\n in which the row occurs. The TID can be addressed in SQL by the name \n `tid.'\n\nSo you can limit the number of rows coming back using something like:\nselect * from SomeTable where tid < 2048\nThe method is somewhat inexact in the number of rows it returns. It's fine for my requirement though because I just want to limit rows coming back from a very large result set to speed up testing. \n\nA:\n\nHey Craig. I'm sorry, I made a Ninja Edit.\nNo, Limit 10 does not work, I was mistaken in thinking it was standard SQL supported by everyone. Ingres uses (according to doc) \"First\" to solve the issue.\n\nA:\n\nHey Ninja editor from Stockholm! No worries, have confirmed that \"first X\" works well and a much nicer solution than I came up with. Thankyou!\n\n"},"title":{"kind":"string","value":"How to limit result set size for arbitrary query in Ingres?"},"question":{"kind":"string","value":"In Oracle, the number of rows returned in an arbitrary query can be limited by filtering on the \"virtual\" rownum column. Consider the following example, which will return, at most, 10 rows.\nSELECT * FROM all_tables WHERE rownum <= 10\nIs there a simple, generic way to do something similar in Ingres?\n"},"answers":{"kind":"list like","value":["Blatantly changing my answer. \"Limit 10\" works for MySql and others, Ingres uses\nSelect First 10 * from myTable\n\nRef\n","select * from myTable limit 10 does not work.\nHave discovered one possible solution:\n\n TIDs are \"tuple identifiers\" or row addresses. The TID contains the\n page number and the index of the offset to the row relative to the\n page boundary. TIDs are presently implemented as 4-byte integers.\n The TID uniquely identifies each row in a table. Every row has a\n TID. The high-order 23 bits of the TID are the page number of the page\n in which the row occurs. The TID can be addressed in SQL by the name \n `tid.'\n\nSo you can limit the number of rows coming back using something like:\nselect * from SomeTable where tid < 2048\nThe method is somewhat inexact in the number of rows it returns. It's fine for my requirement though because I just want to limit rows coming back from a very large result set to speed up testing. \n","Hey Craig. I'm sorry, I made a Ninja Edit.\nNo, Limit 10 does not work, I was mistaken in thinking it was standard SQL supported by everyone. Ingres uses (according to doc) \"First\" to solve the issue.\n","Hey Ninja editor from Stockholm! No worries, have confirmed that \"first X\" works well and a much nicer solution than I came up with. Thankyou!\n"],"string":"[\n \"Blatantly changing my answer. \\\"Limit 10\\\" works for MySql and others, Ingres uses\\nSelect First 10 * from myTable\\n\\nRef\\n\",\n \"select * from myTable limit 10 does not work.\\nHave discovered one possible solution:\\n\\n TIDs are \\\"tuple identifiers\\\" or row addresses. The TID contains the\\n page number and the index of the offset to the row relative to the\\n page boundary. TIDs are presently implemented as 4-byte integers.\\n The TID uniquely identifies each row in a table. Every row has a\\n TID. The high-order 23 bits of the TID are the page number of the page\\n in which the row occurs. The TID can be addressed in SQL by the name \\n `tid.'\\n\\nSo you can limit the number of rows coming back using something like:\\nselect * from SomeTable where tid < 2048\\nThe method is somewhat inexact in the number of rows it returns. It's fine for my requirement though because I just want to limit rows coming back from a very large result set to speed up testing. \\n\",\n \"Hey Craig. I'm sorry, I made a Ninja Edit.\\nNo, Limit 10 does not work, I was mistaken in thinking it was standard SQL supported by everyone. Ingres uses (according to doc) \\\"First\\\" to solve the issue.\\n\",\n \"Hey Ninja editor from Stockholm! No worries, have confirmed that \\\"first X\\\" works well and a much nicer solution than I came up with. Thankyou!\\n\"\n]"},"answers_scores":{"kind":"list like","value":[6,2,0,0],"string":"[\n 6,\n 2,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["ingres","oracle","sql"],"string":"[\n \"ingres\",\n \"oracle\",\n \"sql\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049602_ingres_oracle_sql.txt"}}},{"rowIdx":1577,"cells":{"content":{"kind":"string","value":"Q:\n\nTemplates In VB\n\nI've got some VB code (actually VBA) which is basically the same except for the type on which it operates. Since I think the DRY principle is a good guiding principle for software development, I want to write one routine for all of the different types which need to be operated on. For example if I had two snippets of code like these:\nDim i as Obj1\nSet i = RoutineThatReturnsObj1()\ni.property = newvalue\n\nDim i as Obj2\nSet i = RoutineThatReturnsObj2()\ni.property = newvalue\n\nI'd like to have something like this to handle both instances:\nSub MyRoutine(o as ObjectType, r as RoutineToInitializeObject, newvalue as value) \n Dim i as o\n Set i = r\n i.property = newvalue\nEnd Sub\n\nIf I were using C++ I'd generate a template and say no more about it. But I'm using VBA. I'm fairly sure there's no capability like C++ templates in the VBA language definition but is there any other means by which I might achieve the same effect? I'm guessing the answer is no but I ask here because maybe there is some feature of VBA that I've missed.\n\nA:\n\nThere's nothing in VB6 that will do that. If you update to Visual Studio Tools for Office with .Net you can use generics:\nFunction MyRoutine(Of O)(R As Delegate, newvalue As Object) As O\n Dim i As O = CType(r.Method.Invoke(Nothing, Nothing), O)\n\n 'you need another parameter to tell it which property to use'\n ' and then use reflection to set the value'\n i.property = newvalue \n return i\nEnd Function\n\n"},"title":{"kind":"string","value":"Templates In VB"},"question":{"kind":"string","value":"I've got some VB code (actually VBA) which is basically the same except for the type on which it operates. Since I think the DRY principle is a good guiding principle for software development, I want to write one routine for all of the different types which need to be operated on. For example if I had two snippets of code like these:\nDim i as Obj1\nSet i = RoutineThatReturnsObj1()\ni.property = newvalue\n\nDim i as Obj2\nSet i = RoutineThatReturnsObj2()\ni.property = newvalue\n\nI'd like to have something like this to handle both instances:\nSub MyRoutine(o as ObjectType, r as RoutineToInitializeObject, newvalue as value) \n Dim i as o\n Set i = r\n i.property = newvalue\nEnd Sub\n\nIf I were using C++ I'd generate a template and say no more about it. But I'm using VBA. I'm fairly sure there's no capability like C++ templates in the VBA language definition but is there any other means by which I might achieve the same effect? I'm guessing the answer is no but I ask here because maybe there is some feature of VBA that I've missed.\n"},"answers":{"kind":"list like","value":["There's nothing in VB6 that will do that. If you update to Visual Studio Tools for Office with .Net you can use generics:\nFunction MyRoutine(Of O)(R As Delegate, newvalue As Object) As O\n Dim i As O = CType(r.Method.Invoke(Nothing, Nothing), O)\n\n 'you need another parameter to tell it which property to use'\n ' and then use reflection to set the value'\n i.property = newvalue \n return i\nEnd Function\n\n"],"string":"[\n \"There's nothing in VB6 that will do that. If you update to Visual Studio Tools for Office with .Net you can use generics:\\nFunction MyRoutine(Of O)(R As Delegate, newvalue As Object) As O\\n Dim i As O = CType(r.Method.Invoke(Nothing, Nothing), O)\\n\\n 'you need another parameter to tell it which property to use'\\n ' and then use reflection to set the value'\\n i.property = newvalue \\n return i\\nEnd Function\\n\\n\"\n]"},"answers_scores":{"kind":"list like","value":[1],"string":"[\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["templates","vba"],"string":"[\n \"templates\",\n \"vba\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049718_templates_vba.txt"}}},{"rowIdx":1578,"cells":{"content":{"kind":"string","value":"Q:\n\nIs automatic upgrades a realistic feature to expect from enterprise Web applications?\n\nMost of the work I do is with what could be considered enterprise Web applications. These projects have large budgets, longer timelines (from 3-12 months), and heavy customizations. Because as developers we have been touting the idea of the Web as the next desktop OS, customers are coming to expect the software running on this \"new OS\" to react the same as on the desktop. That includes easy to manage automatic upgrades. In other words, \"An update is available. Do you want to upgrade?\" Is this even a realistic expectation? Can anyone speak from experience on trying to implement this feature?\n\nA:\n\nAt my company we have enterprise installations ranging into the thousands of seats. If we implemented an auto-upgrade, our customers would mutiny!\nLarge installations have peculiar issues that don't apply to small ones. For example, with 2000 users (not all of whom are, let us say, the most sophisticated of tool users), tool-training is a big deal: training time, internal demos, internal process documents, etc.. They cannot unleash a new feature or UI change without a chance to understand how it fits in their process and therefore what their internal best practices are and how to communicate that to their users.\nAlso when applications fail, it's the internal IT team who are responsible. Therefore, they want time to install a new version in a test area, beat it up, and deploy on a Saturday only when they're good and ready.\nI can see the value in making minor patches more easy to install, particularly when the patch is just for a bug-fix and not for anything that would require retraining, and if the admins still get final say over when it's installed. But even then, I don't believe anyone has ever asked for this! Whether because they don't want it or they are trained to not expect it, it doesn't seem worth it.\n\nA:\n\nWell, it really depends on your business model but for a lot of applications the SaaS model can end up biting you. It's great for a lot of things but for some larger applications the users are not investing as significant amount up front and could possibly move to something else before you've made any money.\nSee \nhttp://news.zdnet.com/2424-9595_22-218408.html\nand here\nhttp://www.25hoursaday.com/weblog/2008/07/21/SoftwareAsAServiceWhenYourBusinessModelBecomesAParadox.aspx\nfor more information\n\nA:\n\nOne of the primary reasons to implement an application as a web application is that you get automatic upgrades for free. Why would users be getting prompted for upgrades on a web app?\nFor Windows applications, the \"update is available, do you want to upgrade?\" functionality is provided by Microsoft using ClickOnce, which I have used in an enterprise environment successfully -- there are a few gotchas but for the most part it is a good way to manage automatic deployment and upgrade of Windows apps.\nFor mobile apps, you can also implement auto-upgrades, although it is a little trickier. \nIn any case, to answer your question in a broad sense, I don't know if it is expected that all enterprise apps should make upgrading easy, but it certainly is worth the money from an IT support standpoint to architect them to allow for easy upgrading.\n\nA:\n\nIf you're providing a hosted solution, I wouldn't bother. Let the upgrade happen silently (perhaps with a notice that you did it). If you're selling an application that's hosted on their servers, let the upgrade decision be made by a single owner, not every user of the app.\n\n"},"title":{"kind":"string","value":"Is automatic upgrades a realistic feature to expect from enterprise Web applications?"},"question":{"kind":"string","value":"Most of the work I do is with what could be considered enterprise Web applications. These projects have large budgets, longer timelines (from 3-12 months), and heavy customizations. Because as developers we have been touting the idea of the Web as the next desktop OS, customers are coming to expect the software running on this \"new OS\" to react the same as on the desktop. That includes easy to manage automatic upgrades. In other words, \"An update is available. Do you want to upgrade?\" Is this even a realistic expectation? Can anyone speak from experience on trying to implement this feature?\n"},"answers":{"kind":"list like","value":["At my company we have enterprise installations ranging into the thousands of seats. If we implemented an auto-upgrade, our customers would mutiny!\nLarge installations have peculiar issues that don't apply to small ones. For example, with 2000 users (not all of whom are, let us say, the most sophisticated of tool users), tool-training is a big deal: training time, internal demos, internal process documents, etc.. They cannot unleash a new feature or UI change without a chance to understand how it fits in their process and therefore what their internal best practices are and how to communicate that to their users.\nAlso when applications fail, it's the internal IT team who are responsible. Therefore, they want time to install a new version in a test area, beat it up, and deploy on a Saturday only when they're good and ready.\nI can see the value in making minor patches more easy to install, particularly when the patch is just for a bug-fix and not for anything that would require retraining, and if the admins still get final say over when it's installed. But even then, I don't believe anyone has ever asked for this! Whether because they don't want it or they are trained to not expect it, it doesn't seem worth it.\n","Well, it really depends on your business model but for a lot of applications the SaaS model can end up biting you. It's great for a lot of things but for some larger applications the users are not investing as significant amount up front and could possibly move to something else before you've made any money.\nSee \nhttp://news.zdnet.com/2424-9595_22-218408.html\nand here\nhttp://www.25hoursaday.com/weblog/2008/07/21/SoftwareAsAServiceWhenYourBusinessModelBecomesAParadox.aspx\nfor more information\n","One of the primary reasons to implement an application as a web application is that you get automatic upgrades for free. Why would users be getting prompted for upgrades on a web app?\nFor Windows applications, the \"update is available, do you want to upgrade?\" functionality is provided by Microsoft using ClickOnce, which I have used in an enterprise environment successfully -- there are a few gotchas but for the most part it is a good way to manage automatic deployment and upgrade of Windows apps.\nFor mobile apps, you can also implement auto-upgrades, although it is a little trickier. \nIn any case, to answer your question in a broad sense, I don't know if it is expected that all enterprise apps should make upgrading easy, but it certainly is worth the money from an IT support standpoint to architect them to allow for easy upgrading.\n","If you're providing a hosted solution, I wouldn't bother. Let the upgrade happen silently (perhaps with a notice that you did it). If you're selling an application that's hosted on their servers, let the upgrade decision be made by a single owner, not every user of the app.\n"],"string":"[\n \"At my company we have enterprise installations ranging into the thousands of seats. If we implemented an auto-upgrade, our customers would mutiny!\\nLarge installations have peculiar issues that don't apply to small ones. For example, with 2000 users (not all of whom are, let us say, the most sophisticated of tool users), tool-training is a big deal: training time, internal demos, internal process documents, etc.. They cannot unleash a new feature or UI change without a chance to understand how it fits in their process and therefore what their internal best practices are and how to communicate that to their users.\\nAlso when applications fail, it's the internal IT team who are responsible. Therefore, they want time to install a new version in a test area, beat it up, and deploy on a Saturday only when they're good and ready.\\nI can see the value in making minor patches more easy to install, particularly when the patch is just for a bug-fix and not for anything that would require retraining, and if the admins still get final say over when it's installed. But even then, I don't believe anyone has ever asked for this! Whether because they don't want it or they are trained to not expect it, it doesn't seem worth it.\\n\",\n \"Well, it really depends on your business model but for a lot of applications the SaaS model can end up biting you. It's great for a lot of things but for some larger applications the users are not investing as significant amount up front and could possibly move to something else before you've made any money.\\nSee \\nhttp://news.zdnet.com/2424-9595_22-218408.html\\nand here\\nhttp://www.25hoursaday.com/weblog/2008/07/21/SoftwareAsAServiceWhenYourBusinessModelBecomesAParadox.aspx\\nfor more information\\n\",\n \"One of the primary reasons to implement an application as a web application is that you get automatic upgrades for free. Why would users be getting prompted for upgrades on a web app?\\nFor Windows applications, the \\\"update is available, do you want to upgrade?\\\" functionality is provided by Microsoft using ClickOnce, which I have used in an enterprise environment successfully -- there are a few gotchas but for the most part it is a good way to manage automatic deployment and upgrade of Windows apps.\\nFor mobile apps, you can also implement auto-upgrades, although it is a little trickier. \\nIn any case, to answer your question in a broad sense, I don't know if it is expected that all enterprise apps should make upgrading easy, but it certainly is worth the money from an IT support standpoint to architect them to allow for easy upgrading.\\n\",\n \"If you're providing a hosted solution, I wouldn't bother. Let the upgrade happen silently (perhaps with a notice that you did it). If you're selling an application that's hosted on their servers, let the upgrade decision be made by a single owner, not every user of the app.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[2,1,0,0],"string":"[\n 2,\n 1,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["enterprise","upgrade"],"string":"[\n \"enterprise\",\n \"upgrade\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049732_enterprise_upgrade.txt"}}},{"rowIdx":1579,"cells":{"content":{"kind":"string","value":"Q:\n\nProgrammatically extract macro (VBA) code from Word 2007 docs\n\nIs it possible to extract all of the VBA code from a Word 2007 \"docm\" document using the API?\nI have found how to insert VBA code at runtime, and how to delete all VBA code, but not pull the actual code out into a stream or string that I can store (and insert into other documents in the future).\nAny tips or resources would be appreciated.\nEdit: thanks to everyone, Aardvark's answer was exactly what I was looking for. I have converted his code to C#, and was able to call it from a class library using Visual Studio 2008.\nusing Microsoft.Office.Interop.Word;\nusing Microsoft.Vbe.Interop;\n\n...\n\npublic List GetMacrosFromDoc()\n{\n Document doc = GetWordDoc(@\"C:\\Temp\\test.docm\");\n\n List macros = new List();\n\n VBProject prj;\n CodeModule code;\n string composedFile;\n\n prj = doc.VBProject;\n foreach (VBComponent comp in prj.VBComponents)\n {\n code = comp.CodeModule;\n\n // Put the name of the code module at the top\n composedFile = comp.Name + Environment.NewLine;\n\n // Loop through the (1-indexed) lines\n for (int i = 0; i < code.CountOfLines; i++)\n {\n composedFile += code.get_Lines(i + 1, 1) + Environment.NewLine;\n }\n\n // Add the macro to the list\n macros.Add(composedFile);\n }\n\n CloseDoc(doc);\n\n return macros;\n}\n\nA:\n\nYou could export the code to files and then read them back in.\nI've been using the code below to help me keep some Excel macros under source control (using Subversion & TortoiseSVN). It basically exports all the code to text files any time I save with the VBA editor open. I put the text files in subversion so that I can do diffs. You should be able to adapt/steal some of this to work in Word.\nThe registry check in CanAccessVBOM() corresponds to the \"Trust access to Visual Basic Project\" in the security setting.\nSub ExportCode()\n\n If Not CanAccessVBOM Then Exit Sub ' Exit if access to VB object model is not allowed\n If (ThisWorkbook.VBProject.VBE.ActiveWindow Is Nothing) Then\n Exit Sub ' Exit if VBA window is not open\n End If\n Dim comp As VBComponent\n Dim codeFolder As String\n\n codeFolder = CombinePaths(GetWorkbookPath, \"Code\")\n On Error Resume Next\n MkDir codeFolder\n On Error GoTo 0\n Dim FileName As String\n\n For Each comp In ThisWorkbook.VBProject.VBComponents\n Select Case comp.Type\n Case vbext_ct_ClassModule\n FileName = CombinePaths(codeFolder, comp.Name & \".cls\")\n DeleteFile FileName\n comp.Export FileName\n Case vbext_ct_StdModule\n FileName = CombinePaths(codeFolder, comp.Name & \".bas\")\n DeleteFile FileName\n comp.Export FileName\n Case vbext_ct_MSForm\n FileName = CombinePaths(codeFolder, comp.Name & \".frm\")\n DeleteFile FileName\n comp.Export FileName\n Case vbext_ct_Document\n FileName = CombinePaths(codeFolder, comp.Name & \".cls\")\n DeleteFile FileName\n comp.Export FileName\n End Select\n Next\n\nEnd Sub\nFunction CanAccessVBOM() As Boolean\n ' Check resgistry to see if we can access the VB object model\n Dim wsh As Object\n Dim str1 As String\n Dim AccessVBOM As Long\n\n Set wsh = CreateObject(\"WScript.Shell\")\n str1 = \"HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\\" & _\n Application.Version & \"\\Excel\\Security\\AccessVBOM\"\n On Error Resume Next\n AccessVBOM = wsh.RegRead(str1)\n Set wsh = Nothing\n CanAccessVBOM = (AccessVBOM = 1)\nEnd Function\n\nSub DeleteFile(FileName As String)\n On Error Resume Next\n Kill FileName\nEnd Sub\n\nFunction GetWorkbookPath() As String\n Dim fullName As String\n Dim wrkbookName As String\n Dim pos As Long\n\n wrkbookName = ThisWorkbook.Name\n fullName = ThisWorkbook.fullName\n\n pos = InStr(1, fullName, wrkbookName, vbTextCompare)\n\n GetWorkbookPath = Left$(fullName, pos - 1)\nEnd Function\n\nFunction CombinePaths(ByVal Path1 As String, ByVal Path2 As String) As String\n If Not EndsWith(Path1, \"\\\") Then\n Path1 = Path1 & \"\\\"\n End If\n CombinePaths = Path1 & Path2\nEnd Function\n\nFunction EndsWith(ByVal InString As String, ByVal TestString As String) As Boolean\n EndsWith = (Right$(InString, Len(TestString)) = TestString)\nEnd Function\n\nA:\n\nYou'll have to add a reference to Microsoft Visual Basic for Applications Extensibility 5.3 (or whatever version you have). I have the VBA SDK and such on my box - so this may not be exactly what office ships with.\nAlso you have to enable access to the VBA Object Model specifically - see the \"Trust Center\" in Word options. This is in addition to all the other Macro security settings Office provides.\nThis example will extract code from the current document it lives in - it itself is a VBA macro (and will display itself and any other code as well). There is also a Application.vbe.VBProjects collection to access other documents. While I've never done it, I assume an external application could get to open files using this VBProjects collection as well. Security is funny with this stuff so it may be tricky.\nI also wonder what the docm file format is now - XML like the docx? Would that be a better approach? \nSub GetCode()\n\n Dim prj As VBProject\n Dim comp As VBComponent\n Dim code As CodeModule\n Dim composedFile As String\n Dim i As Integer\n\n Set prj = ThisDocument.VBProject\n For Each comp In prj.VBComponents\n Set code = comp.CodeModule\n\n composedFile = comp.Name & vbNewLine\n\n For i = 1 To code.CountOfLines\n composedFile = composedFile & code.Lines(i, 1) & vbNewLine\n Next\n\n MsgBox composedFile\n Next\n\nEnd Sub\n\n"},"title":{"kind":"string","value":"Programmatically extract macro (VBA) code from Word 2007 docs"},"question":{"kind":"string","value":"Is it possible to extract all of the VBA code from a Word 2007 \"docm\" document using the API?\nI have found how to insert VBA code at runtime, and how to delete all VBA code, but not pull the actual code out into a stream or string that I can store (and insert into other documents in the future).\nAny tips or resources would be appreciated.\nEdit: thanks to everyone, Aardvark's answer was exactly what I was looking for. I have converted his code to C#, and was able to call it from a class library using Visual Studio 2008.\nusing Microsoft.Office.Interop.Word;\nusing Microsoft.Vbe.Interop;\n\n...\n\npublic List GetMacrosFromDoc()\n{\n Document doc = GetWordDoc(@\"C:\\Temp\\test.docm\");\n\n List macros = new List();\n\n VBProject prj;\n CodeModule code;\n string composedFile;\n\n prj = doc.VBProject;\n foreach (VBComponent comp in prj.VBComponents)\n {\n code = comp.CodeModule;\n\n // Put the name of the code module at the top\n composedFile = comp.Name + Environment.NewLine;\n\n // Loop through the (1-indexed) lines\n for (int i = 0; i < code.CountOfLines; i++)\n {\n composedFile += code.get_Lines(i + 1, 1) + Environment.NewLine;\n }\n\n // Add the macro to the list\n macros.Add(composedFile);\n }\n\n CloseDoc(doc);\n\n return macros;\n}\n\n"},"answers":{"kind":"list like","value":["You could export the code to files and then read them back in.\nI've been using the code below to help me keep some Excel macros under source control (using Subversion & TortoiseSVN). It basically exports all the code to text files any time I save with the VBA editor open. I put the text files in subversion so that I can do diffs. You should be able to adapt/steal some of this to work in Word.\nThe registry check in CanAccessVBOM() corresponds to the \"Trust access to Visual Basic Project\" in the security setting.\nSub ExportCode()\n\n If Not CanAccessVBOM Then Exit Sub ' Exit if access to VB object model is not allowed\n If (ThisWorkbook.VBProject.VBE.ActiveWindow Is Nothing) Then\n Exit Sub ' Exit if VBA window is not open\n End If\n Dim comp As VBComponent\n Dim codeFolder As String\n\n codeFolder = CombinePaths(GetWorkbookPath, \"Code\")\n On Error Resume Next\n MkDir codeFolder\n On Error GoTo 0\n Dim FileName As String\n\n For Each comp In ThisWorkbook.VBProject.VBComponents\n Select Case comp.Type\n Case vbext_ct_ClassModule\n FileName = CombinePaths(codeFolder, comp.Name & \".cls\")\n DeleteFile FileName\n comp.Export FileName\n Case vbext_ct_StdModule\n FileName = CombinePaths(codeFolder, comp.Name & \".bas\")\n DeleteFile FileName\n comp.Export FileName\n Case vbext_ct_MSForm\n FileName = CombinePaths(codeFolder, comp.Name & \".frm\")\n DeleteFile FileName\n comp.Export FileName\n Case vbext_ct_Document\n FileName = CombinePaths(codeFolder, comp.Name & \".cls\")\n DeleteFile FileName\n comp.Export FileName\n End Select\n Next\n\nEnd Sub\nFunction CanAccessVBOM() As Boolean\n ' Check resgistry to see if we can access the VB object model\n Dim wsh As Object\n Dim str1 As String\n Dim AccessVBOM As Long\n\n Set wsh = CreateObject(\"WScript.Shell\")\n str1 = \"HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\\" & _\n Application.Version & \"\\Excel\\Security\\AccessVBOM\"\n On Error Resume Next\n AccessVBOM = wsh.RegRead(str1)\n Set wsh = Nothing\n CanAccessVBOM = (AccessVBOM = 1)\nEnd Function\n\n\nSub DeleteFile(FileName As String)\n On Error Resume Next\n Kill FileName\nEnd Sub\n\nFunction GetWorkbookPath() As String\n Dim fullName As String\n Dim wrkbookName As String\n Dim pos As Long\n\n wrkbookName = ThisWorkbook.Name\n fullName = ThisWorkbook.fullName\n\n pos = InStr(1, fullName, wrkbookName, vbTextCompare)\n\n GetWorkbookPath = Left$(fullName, pos - 1)\nEnd Function\n\nFunction CombinePaths(ByVal Path1 As String, ByVal Path2 As String) As String\n If Not EndsWith(Path1, \"\\\") Then\n Path1 = Path1 & \"\\\"\n End If\n CombinePaths = Path1 & Path2\nEnd Function\n\nFunction EndsWith(ByVal InString As String, ByVal TestString As String) As Boolean\n EndsWith = (Right$(InString, Len(TestString)) = TestString)\nEnd Function\n\n","You'll have to add a reference to Microsoft Visual Basic for Applications Extensibility 5.3 (or whatever version you have). I have the VBA SDK and such on my box - so this may not be exactly what office ships with.\nAlso you have to enable access to the VBA Object Model specifically - see the \"Trust Center\" in Word options. This is in addition to all the other Macro security settings Office provides.\nThis example will extract code from the current document it lives in - it itself is a VBA macro (and will display itself and any other code as well). There is also a Application.vbe.VBProjects collection to access other documents. While I've never done it, I assume an external application could get to open files using this VBProjects collection as well. Security is funny with this stuff so it may be tricky.\nI also wonder what the docm file format is now - XML like the docx? Would that be a better approach? \nSub GetCode()\n\n Dim prj As VBProject\n Dim comp As VBComponent\n Dim code As CodeModule\n Dim composedFile As String\n Dim i As Integer\n\n Set prj = ThisDocument.VBProject\n For Each comp In prj.VBComponents\n Set code = comp.CodeModule\n\n composedFile = comp.Name & vbNewLine\n\n For i = 1 To code.CountOfLines\n composedFile = composedFile & code.Lines(i, 1) & vbNewLine\n Next\n\n MsgBox composedFile\n Next\n\nEnd Sub\n\n"],"string":"[\n \"You could export the code to files and then read them back in.\\nI've been using the code below to help me keep some Excel macros under source control (using Subversion & TortoiseSVN). It basically exports all the code to text files any time I save with the VBA editor open. I put the text files in subversion so that I can do diffs. You should be able to adapt/steal some of this to work in Word.\\nThe registry check in CanAccessVBOM() corresponds to the \\\"Trust access to Visual Basic Project\\\" in the security setting.\\nSub ExportCode()\\n\\n If Not CanAccessVBOM Then Exit Sub ' Exit if access to VB object model is not allowed\\n If (ThisWorkbook.VBProject.VBE.ActiveWindow Is Nothing) Then\\n Exit Sub ' Exit if VBA window is not open\\n End If\\n Dim comp As VBComponent\\n Dim codeFolder As String\\n\\n codeFolder = CombinePaths(GetWorkbookPath, \\\"Code\\\")\\n On Error Resume Next\\n MkDir codeFolder\\n On Error GoTo 0\\n Dim FileName As String\\n\\n For Each comp In ThisWorkbook.VBProject.VBComponents\\n Select Case comp.Type\\n Case vbext_ct_ClassModule\\n FileName = CombinePaths(codeFolder, comp.Name & \\\".cls\\\")\\n DeleteFile FileName\\n comp.Export FileName\\n Case vbext_ct_StdModule\\n FileName = CombinePaths(codeFolder, comp.Name & \\\".bas\\\")\\n DeleteFile FileName\\n comp.Export FileName\\n Case vbext_ct_MSForm\\n FileName = CombinePaths(codeFolder, comp.Name & \\\".frm\\\")\\n DeleteFile FileName\\n comp.Export FileName\\n Case vbext_ct_Document\\n FileName = CombinePaths(codeFolder, comp.Name & \\\".cls\\\")\\n DeleteFile FileName\\n comp.Export FileName\\n End Select\\n Next\\n\\nEnd Sub\\nFunction CanAccessVBOM() As Boolean\\n ' Check resgistry to see if we can access the VB object model\\n Dim wsh As Object\\n Dim str1 As String\\n Dim AccessVBOM As Long\\n\\n Set wsh = CreateObject(\\\"WScript.Shell\\\")\\n str1 = \\\"HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Office\\\\\\\" & _\\n Application.Version & \\\"\\\\Excel\\\\Security\\\\AccessVBOM\\\"\\n On Error Resume Next\\n AccessVBOM = wsh.RegRead(str1)\\n Set wsh = Nothing\\n CanAccessVBOM = (AccessVBOM = 1)\\nEnd Function\\n\\n\\nSub DeleteFile(FileName As String)\\n On Error Resume Next\\n Kill FileName\\nEnd Sub\\n\\nFunction GetWorkbookPath() As String\\n Dim fullName As String\\n Dim wrkbookName As String\\n Dim pos As Long\\n\\n wrkbookName = ThisWorkbook.Name\\n fullName = ThisWorkbook.fullName\\n\\n pos = InStr(1, fullName, wrkbookName, vbTextCompare)\\n\\n GetWorkbookPath = Left$(fullName, pos - 1)\\nEnd Function\\n\\nFunction CombinePaths(ByVal Path1 As String, ByVal Path2 As String) As String\\n If Not EndsWith(Path1, \\\"\\\\\\\") Then\\n Path1 = Path1 & \\\"\\\\\\\"\\n End If\\n CombinePaths = Path1 & Path2\\nEnd Function\\n\\nFunction EndsWith(ByVal InString As String, ByVal TestString As String) As Boolean\\n EndsWith = (Right$(InString, Len(TestString)) = TestString)\\nEnd Function\\n\\n\",\n \"You'll have to add a reference to Microsoft Visual Basic for Applications Extensibility 5.3 (or whatever version you have). I have the VBA SDK and such on my box - so this may not be exactly what office ships with.\\nAlso you have to enable access to the VBA Object Model specifically - see the \\\"Trust Center\\\" in Word options. This is in addition to all the other Macro security settings Office provides.\\nThis example will extract code from the current document it lives in - it itself is a VBA macro (and will display itself and any other code as well). There is also a Application.vbe.VBProjects collection to access other documents. While I've never done it, I assume an external application could get to open files using this VBProjects collection as well. Security is funny with this stuff so it may be tricky.\\nI also wonder what the docm file format is now - XML like the docx? Would that be a better approach? \\nSub GetCode()\\n\\n Dim prj As VBProject\\n Dim comp As VBComponent\\n Dim code As CodeModule\\n Dim composedFile As String\\n Dim i As Integer\\n\\n Set prj = ThisDocument.VBProject\\n For Each comp In prj.VBComponents\\n Set code = comp.CodeModule\\n\\n composedFile = comp.Name & vbNewLine\\n\\n For i = 1 To code.CountOfLines\\n composedFile = composedFile & code.Lines(i, 1) & vbNewLine\\n Next\\n\\n MsgBox composedFile\\n Next\\n\\nEnd Sub\\n\\n\"\n]"},"answers_scores":{"kind":"list like","value":[29,11],"string":"[\n 29,\n 11\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":[".net","automation","ms_office"],"string":"[\n \".net\",\n \"automation\",\n \"ms_office\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049724_.net_automation_ms_office.txt"}}},{"rowIdx":1580,"cells":{"content":{"kind":"string","value":"Q:\n\nLINQ and Database Permissions\n\nI'm still trying to get my head around LINQ and accessing a SQL Database.\nI was always taught that you should only have execute permissions of stored procedures to your data.\nYou should never have select / insert / update / delete.\n(This is because of performance and security)\nTo get the data out of LINQ you obviously need select permissions. I know you can use stored procs with LINQ, but since I can't do joins what's the point?\nHave I missed something???\n\nA:\n\n1) We're programmers, not DBA fascists. If your requirements state that the database must be locked down 100%, Linq is not for you. I'm not a DBA, so I believe that most of the performance/security hype is just that. Linq is for me.\n2) You can do joins with linq.\n@Philippe: Linq automatically transforms evaluations into query parameters, so it provides some sql injection protection. However, you still have to closely evaluate your requirements to determine how much security you need and at what levels. Linq makes dealing with the database much easier, but it makes it easier to put secuirty design on the back burner, which is a bad thing. \n\nA:\n\nI'm very much in agreement with Jeff Atwood on the \"Stored Procedures vs. Inline SQL/LINQ\" issue: Who Needs Stored Procedures, Anyways?.\nI'm confused as to why you'd even want to perform a JOIN if you're in the SPROCs-for-everything crowd; shouldn't you wrap that JOIN up into another SPROC?\nAs Will said, LINQ wasn't designed for the kind of DB use you're talking about; it was designed to give us statically-typed inline SQL. You could, however, still control access through user permissions if you use LINQ to SQL.\n\nA:\n\nWell, for security reasons you should not input any user entered data into queries. If you stick with this rule, I don't see the problem of having select permission.\n\nA:\n\nWhether all of your database access is \"behind\" stored procedures depends on the needs of the application and the company. I have implemented systems that use views to get all data and stored procedures for all updates. This allows for centralized security and database logic while still letting front-end developers use SQL queries where appropriate.\nLike so many other things in programming - it depends on the needs for your project.\nLinqToSql does support stored procedures. Scott Gu has a post on it:\nhttp://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx\n\n"},"title":{"kind":"string","value":"LINQ and Database Permissions"},"question":{"kind":"string","value":"I'm still trying to get my head around LINQ and accessing a SQL Database.\nI was always taught that you should only have execute permissions of stored procedures to your data.\nYou should never have select / insert / update / delete.\n(This is because of performance and security)\nTo get the data out of LINQ you obviously need select permissions. I know you can use stored procs with LINQ, but since I can't do joins what's the point?\nHave I missed something???\n"},"answers":{"kind":"list like","value":["1) We're programmers, not DBA fascists. If your requirements state that the database must be locked down 100%, Linq is not for you. I'm not a DBA, so I believe that most of the performance/security hype is just that. Linq is for me.\n2) You can do joins with linq.\n@Philippe: Linq automatically transforms evaluations into query parameters, so it provides some sql injection protection. However, you still have to closely evaluate your requirements to determine how much security you need and at what levels. Linq makes dealing with the database much easier, but it makes it easier to put secuirty design on the back burner, which is a bad thing. \n","I'm very much in agreement with Jeff Atwood on the \"Stored Procedures vs. Inline SQL/LINQ\" issue: Who Needs Stored Procedures, Anyways?.\nI'm confused as to why you'd even want to perform a JOIN if you're in the SPROCs-for-everything crowd; shouldn't you wrap that JOIN up into another SPROC?\nAs Will said, LINQ wasn't designed for the kind of DB use you're talking about; it was designed to give us statically-typed inline SQL. You could, however, still control access through user permissions if you use LINQ to SQL.\n","Well, for security reasons you should not input any user entered data into queries. If you stick with this rule, I don't see the problem of having select permission.\n","Whether all of your database access is \"behind\" stored procedures depends on the needs of the application and the company. I have implemented systems that use views to get all data and stored procedures for all updates. This allows for centralized security and database logic while still letting front-end developers use SQL queries where appropriate.\nLike so many other things in programming - it depends on the needs for your project.\nLinqToSql does support stored procedures. Scott Gu has a post on it:\nhttp://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx\n"],"string":"[\n \"1) We're programmers, not DBA fascists. If your requirements state that the database must be locked down 100%, Linq is not for you. I'm not a DBA, so I believe that most of the performance/security hype is just that. Linq is for me.\\n2) You can do joins with linq.\\n@Philippe: Linq automatically transforms evaluations into query parameters, so it provides some sql injection protection. However, you still have to closely evaluate your requirements to determine how much security you need and at what levels. Linq makes dealing with the database much easier, but it makes it easier to put secuirty design on the back burner, which is a bad thing. \\n\",\n \"I'm very much in agreement with Jeff Atwood on the \\\"Stored Procedures vs. Inline SQL/LINQ\\\" issue: Who Needs Stored Procedures, Anyways?.\\nI'm confused as to why you'd even want to perform a JOIN if you're in the SPROCs-for-everything crowd; shouldn't you wrap that JOIN up into another SPROC?\\nAs Will said, LINQ wasn't designed for the kind of DB use you're talking about; it was designed to give us statically-typed inline SQL. You could, however, still control access through user permissions if you use LINQ to SQL.\\n\",\n \"Well, for security reasons you should not input any user entered data into queries. If you stick with this rule, I don't see the problem of having select permission.\\n\",\n \"Whether all of your database access is \\\"behind\\\" stored procedures depends on the needs of the application and the company. I have implemented systems that use views to get all data and stored procedures for all updates. This allows for centralized security and database logic while still letting front-end developers use SQL queries where appropriate.\\nLike so many other things in programming - it depends on the needs for your project.\\nLinqToSql does support stored procedures. Scott Gu has a post on it:\\nhttp://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx\\n\"\n]"},"answers_scores":{"kind":"list like","value":[2,0,0,0],"string":"[\n 2,\n 0,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["linq_to_sql","permissions"],"string":"[\n \"linq_to_sql\",\n \"permissions\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049551_linq_to_sql_permissions.txt"}}},{"rowIdx":1581,"cells":{"content":{"kind":"string","value":"Q:\n\nApache rewrite based on subdomain\n\nI'm trying to redirect requests for a wildcard domain to a sub-directory.\nie. something.blah.example.com --> blah.example.com/something\nI don't know how to get the subdomain name to use in the rewrite rule.\nFinal Solution:\nRewriteCond %{HTTP_HOST} !^blah\\.example\\.com\nRewriteCond %{HTTP_HOST} ^([^.]+)\nRewriteRule ^(.*) /%1/$1 [L]\n\nOr as pointed out by pilif\nRewriteCond %{HTTP_HOST} ^([^.]+)\\.blah\\.example\\.com$\n\nA:\n\nYou should have a look at the URL Rewriting Guide from the apache documentation.\nThe following is untested, but it should to the trick:\nRewriteCond %{HTTP_HOST} ^([^.]+)\\.blah\\.domain\\.com$\nRewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] \n\nThis only works if the subdomain contains no dots. Otherwise, you'd have to alter the Regexp in RewriteCond to match any character which should still work due to the anchoring, but this certainly feels safer.\n\nA:\n\nTry this:\nRewriteCond %{HTTP_HOST} (.+)\\.blah\\.domain\\.com\nRewriteRule ^(.+)$ /%1/$1 [L]\n\n@pilif (see comment): Okay, that's true. I just copied a .htaccess that I use on one of my projects. Guess it has a slightly different approach :)\n\nA:\n\n@Sam\nyour RewriteCond line is wrong. The expansion of the variable is triggered with %, not $.\nRewriteCond %{HTTP_HOST} ^([^\\.]+)\\.media\\.xnet\\.tk$\n ^\n\nthat should do the trick\n\n"},"title":{"kind":"string","value":"Apache rewrite based on subdomain"},"question":{"kind":"string","value":"I'm trying to redirect requests for a wildcard domain to a sub-directory.\nie. something.blah.example.com --> blah.example.com/something\nI don't know how to get the subdomain name to use in the rewrite rule.\nFinal Solution:\nRewriteCond %{HTTP_HOST} !^blah\\.example\\.com\nRewriteCond %{HTTP_HOST} ^([^.]+)\nRewriteRule ^(.*) /%1/$1 [L]\n\nOr as pointed out by pilif\nRewriteCond %{HTTP_HOST} ^([^.]+)\\.blah\\.example\\.com$\n\n"},"answers":{"kind":"list like","value":["You should have a look at the URL Rewriting Guide from the apache documentation.\nThe following is untested, but it should to the trick:\nRewriteCond %{HTTP_HOST} ^([^.]+)\\.blah\\.domain\\.com$\nRewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] \n\nThis only works if the subdomain contains no dots. Otherwise, you'd have to alter the Regexp in RewriteCond to match any character which should still work due to the anchoring, but this certainly feels safer.\n","Try this:\nRewriteCond %{HTTP_HOST} (.+)\\.blah\\.domain\\.com\nRewriteRule ^(.+)$ /%1/$1 [L]\n\n@pilif (see comment): Okay, that's true. I just copied a .htaccess that I use on one of my projects. Guess it has a slightly different approach :)\n","@Sam\nyour RewriteCond line is wrong. The expansion of the variable is triggered with %, not $.\nRewriteCond %{HTTP_HOST} ^([^\\.]+)\\.media\\.xnet\\.tk$\n ^\n\nthat should do the trick\n"],"string":"[\n \"You should have a look at the URL Rewriting Guide from the apache documentation.\\nThe following is untested, but it should to the trick:\\nRewriteCond %{HTTP_HOST} ^([^.]+)\\\\.blah\\\\.domain\\\\.com$\\nRewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] \\n\\nThis only works if the subdomain contains no dots. Otherwise, you'd have to alter the Regexp in RewriteCond to match any character which should still work due to the anchoring, but this certainly feels safer.\\n\",\n \"Try this:\\nRewriteCond %{HTTP_HOST} (.+)\\\\.blah\\\\.domain\\\\.com\\nRewriteRule ^(.+)$ /%1/$1 [L]\\n\\n@pilif (see comment): Okay, that's true. I just copied a .htaccess that I use on one of my projects. Guess it has a slightly different approach :)\\n\",\n \"@Sam\\nyour RewriteCond line is wrong. The expansion of the variable is triggered with %, not $.\\nRewriteCond %{HTTP_HOST} ^([^\\\\.]+)\\\\.media\\\\.xnet\\\\.tk$\\n ^\\n\\nthat should do the trick\\n\"\n]"},"answers_scores":{"kind":"list like","value":[36,4,1],"string":"[\n 36,\n 4,\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["apache","mod_rewrite","redirect","subdomain","wildcard_subdomain"],"string":"[\n \"apache\",\n \"mod_rewrite\",\n \"redirect\",\n \"subdomain\",\n \"wildcard_subdomain\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049500_apache_mod_rewrite_redirect_subdomain_wildcard_subdomain.txt"}}},{"rowIdx":1582,"cells":{"content":{"kind":"string","value":"Q:\n\nHow can I overwrite the same portion of the console in a Windows native C++ console app, without using a 3rd Party library?\n\nI have a console app that needs to display the state of items, but rather than having text scroll by like mad I'd rather see the current status keep showing up on the same lines. For the sake of example:\n\nRunning... nn% complete\nBuffer size: bbbb bytes\n\nshould be the output, where 'nn' is the current percentage complete, and 'bbbb' is a buffer size, updated periodically on the same lines of the console.\nThe first approach I took simply printed the correct number of backspaces to the console before printing the new state, but this has an obnoxious flicker that I want to get rid of. I also want to stick to either standard library or MS-provided functionality (VC 8) so as not to introduce another dependency for this one simple need.\n\nA:\n\nYou can use SetConsoleCursorPosition. You'll need to call GetStdHandle to get a handle to the output buffer.\n\nA:\n\nJoseph, JP, and CodingTheWheel all provided valuable help.\nFor my simple case, the most straight-forward approach seemed to be based on CodingTheWheel's answer:\n// before entering update loop\nHANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);\nCONSOLE_SCREEN_BUFFER_INFO bufferInfo;\nGetConsoleScreenBufferInfo(h, &bufferInfo);\n\n// update loop\nwhile (updating)\n{\n // reset the cursor position to where it was each time\n SetConsoleCursorPosition(h, bufferInfo.dwCursorPosition);\n\n //...\n // insert combinations of sprintf, printf, etc. here\n //...\n}\n\nFor more complicated problems, the full console API as provided by JP's answer, in coordination with the examples provided via the link from Joseph's answer may prove useful, but I found the work necessary to use CHAR_INFO too tedious for such a simple app.\n\nA:\n\nIf you print using \\r and don't use a function that will generate a newline or add \\n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up. Generating the complete string before printing might reduce flicker as well.\nUPDATE: The question has been changed to 2 lines of output instead of 1 which makes my answer no longer complete. A more complicated approach is likely necessary. JP has the right idea with the Console API. I believe the following site details many of the things you will need to accomplish your goal. The site also mentions that the key to reducing flicker is to render everything offscreen before displaying it. This is true whenever you are displaying anything on the screen whether it is text or graphics (2D or 3D).\nhttp://www.benryves.com/tutorials/?t=winconsole\n\nA:\n\nIn case the Joseph's suggestion does not give you enough flexibility, have a look at the Console API: http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx.\n\nA:\n\nIn Linux, you can accomplish this by printing \\b and/or \\r to stderr. You might need to experiment to find the right combination of things in Windows.\n\n"},"title":{"kind":"string","value":"How can I overwrite the same portion of the console in a Windows native C++ console app, without using a 3rd Party library?"},"question":{"kind":"string","value":"I have a console app that needs to display the state of items, but rather than having text scroll by like mad I'd rather see the current status keep showing up on the same lines. For the sake of example:\n\nRunning... nn% complete\nBuffer size: bbbb bytes\n\nshould be the output, where 'nn' is the current percentage complete, and 'bbbb' is a buffer size, updated periodically on the same lines of the console.\nThe first approach I took simply printed the correct number of backspaces to the console before printing the new state, but this has an obnoxious flicker that I want to get rid of. I also want to stick to either standard library or MS-provided functionality (VC 8) so as not to introduce another dependency for this one simple need.\n"},"answers":{"kind":"list like","value":["You can use SetConsoleCursorPosition. You'll need to call GetStdHandle to get a handle to the output buffer.\n","Joseph, JP, and CodingTheWheel all provided valuable help.\nFor my simple case, the most straight-forward approach seemed to be based on CodingTheWheel's answer:\n// before entering update loop\nHANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);\nCONSOLE_SCREEN_BUFFER_INFO bufferInfo;\nGetConsoleScreenBufferInfo(h, &bufferInfo);\n\n// update loop\nwhile (updating)\n{\n // reset the cursor position to where it was each time\n SetConsoleCursorPosition(h, bufferInfo.dwCursorPosition);\n\n //...\n // insert combinations of sprintf, printf, etc. here\n //...\n}\n\nFor more complicated problems, the full console API as provided by JP's answer, in coordination with the examples provided via the link from Joseph's answer may prove useful, but I found the work necessary to use CHAR_INFO too tedious for such a simple app.\n","If you print using \\r and don't use a function that will generate a newline or add \\n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up. Generating the complete string before printing might reduce flicker as well.\nUPDATE: The question has been changed to 2 lines of output instead of 1 which makes my answer no longer complete. A more complicated approach is likely necessary. JP has the right idea with the Console API. I believe the following site details many of the things you will need to accomplish your goal. The site also mentions that the key to reducing flicker is to render everything offscreen before displaying it. This is true whenever you are displaying anything on the screen whether it is text or graphics (2D or 3D).\nhttp://www.benryves.com/tutorials/?t=winconsole\n","In case the Joseph's suggestion does not give you enough flexibility, have a look at the Console API: http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx.\n","In Linux, you can accomplish this by printing \\b and/or \\r to stderr. You might need to experiment to find the right combination of things in Windows.\n"],"string":"[\n \"You can use SetConsoleCursorPosition. You'll need to call GetStdHandle to get a handle to the output buffer.\\n\",\n \"Joseph, JP, and CodingTheWheel all provided valuable help.\\nFor my simple case, the most straight-forward approach seemed to be based on CodingTheWheel's answer:\\n// before entering update loop\\nHANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);\\nCONSOLE_SCREEN_BUFFER_INFO bufferInfo;\\nGetConsoleScreenBufferInfo(h, &bufferInfo);\\n\\n// update loop\\nwhile (updating)\\n{\\n // reset the cursor position to where it was each time\\n SetConsoleCursorPosition(h, bufferInfo.dwCursorPosition);\\n\\n //...\\n // insert combinations of sprintf, printf, etc. here\\n //...\\n}\\n\\nFor more complicated problems, the full console API as provided by JP's answer, in coordination with the examples provided via the link from Joseph's answer may prove useful, but I found the work necessary to use CHAR_INFO too tedious for such a simple app.\\n\",\n \"If you print using \\\\r and don't use a function that will generate a newline or add \\\\n to the end, the cursor will go back to the beginning of the line and just print over the next thing you put up. Generating the complete string before printing might reduce flicker as well.\\nUPDATE: The question has been changed to 2 lines of output instead of 1 which makes my answer no longer complete. A more complicated approach is likely necessary. JP has the right idea with the Console API. I believe the following site details many of the things you will need to accomplish your goal. The site also mentions that the key to reducing flicker is to render everything offscreen before displaying it. This is true whenever you are displaying anything on the screen whether it is text or graphics (2D or 3D).\\nhttp://www.benryves.com/tutorials/?t=winconsole\\n\",\n \"In case the Joseph's suggestion does not give you enough flexibility, have a look at the Console API: http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx.\\n\",\n \"In Linux, you can accomplish this by printing \\\\b and/or \\\\r to stderr. You might need to experiment to find the right combination of things in Windows.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[8,7,5,3,0],"string":"[\n 8,\n 7,\n 5,\n 3,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["c++","console","windows"],"string":"[\n \"c++\",\n \"console\",\n \"windows\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000045286_c++_console_windows.txt"}}},{"rowIdx":1583,"cells":{"content":{"kind":"string","value":"Q:\n\nWhat is a good design when trying to build objects from a list of key value pairs?\n\nSo if I have a method of parsing a text file and returning a list of a list of key value pairs, and want to create objects from the kvps returned (each list of kvps represents a different object), what would be the best method?\nThe first method that pops into mind is pretty simple, just keep a list of keywords:\nprivate const string NAME = \"name\";\nprivate const string PREFIX = \"prefix\";\n\nand check against the keys I get for the constants I want, defined above. This is a fairly core piece of the project I'm working on though, so I want to do it well; does anyone have any more robust suggestions (not saying there's anything inherently un-robust about the above method - I'm just asking around)?\nEdit:\nMore details have been asked for. I'm working on a little game in my spare time, and I am building up the game world with configuration files. There are four - one defines all creatures, another defines all areas (and their locations in a map), another all objects, and a final one defines various configuration options and things that don't fit else where. With the first three configuration files, I will be creating objects based on the content of the files - it will be quite text-heavy, so there will be a lot of strings, things like names, plurals, prefixes - that sort of thing. The configuration values are all like so:\n-\nkey: value \nkey: value\n-\nkey: value\nkey: value\n-\n\nWhere the '-' line denotes a new section/object.\n\nA:\n\nTake a deep look at the XmlSerializer. Even if you are constrained to not use XML on-disk, you might want to copy some of its features. This could then look like this:\npublic class DataObject {\n [Column(\"name\")]\n public string Name { get; set; }\n\n [Column(\"prefix\")]\n public string Prefix { get; set; }\n}\n\nBe careful though to include some kind of format version in your files, or you will be in hell's kitchen come the next format change.\n\nA:\n\nMaking a lot of unwarranted assumptions, I think that the best approach would be to create a Factory that will receive the list of key value pairs and return the proper object or throw an exception if it's invalid (or create a dummy object, or whatever is better in the particular case).\nprivate class Factory {\n\n public static IConfigurationObject Factory(List keyValuePair) {\n\n switch (keyValuePair[0]) {\n\n case \"x\":\n return new x(keyValuePair[1]);\n break;\n /* etc. */\n default:\n throw new ArgumentException(\"Wrong parameter in the file\");\n }\n\n }\n\n}\n\nThe strongest assumption here is that all your objects can be treated partly like the same (ie, they implement the same interface (IConfigurationObject in the example) or belong to the same inheritance tree).\nIf they don't, then it depends on your program flow and what are you doing with them. But nonetheless, they should :)\nEDIT: Given your explanation, you could have one Factory per file type, the switch in it would be the authoritative source on the allowed types per file type and they probably share something in common. Reflection is possible, but it's riskier because it's less obvious and self documenting than this one.\n\nA:\n\nWhat do you need object for? The way you describe it, you'll use them as some kind (of key-wise) restricted map anyway. If you do not need some kind of inheritance, I'd simply wrap a map-like structure into a object like this:\n[java-inspired pseudo-code:]\nclass RestrictedKVDataStore {\n const ALLOWED_KEYS = new Collection('name', 'prefix');\n Map data = new Map();\n\n void put(String key, Object value) {\n if (ALLOWED_KEYS.contains(key))\n data.put(key, value)\n }\n\n Object get(String key) {\n return data.get(key);\n }\n}\n\nA:\n\nYou could create an interface that matched the column names, and then use the Reflection.Emit API to create a type at runtime that gave access to the data in the fields.\n\nA:\n\nEDIT: \nScratch that, this still applies, but I think what your doing is reading a configuration file and parsing it into this:\nList>> itemConfig = \n new List>>();\n\nIn this case, we can still use a reflection factory to instantiate the objects, I'd just pass in the nested inner list to it, instead of passing each individual key/value pair.\nOLD POST:\nHere is a clever little way to do this using reflection:\nThe basic idea:\n\nUse a common base class for each Object class.\nPut all of these classes in their own assembly.\nPut this factory in that assembly too.\nPass in the KeyValuePair that you read from your config, and in return it finds the class that matches KV.Key and instantiates it with KV.Value\n\n \n public class KeyValueToObjectFactory\n { \n private Dictionary _kvTypes = new Dictionary();\n\n public KeyValueToObjectFactory()\n {\n // Preload the Types into a dictionary so we can look them up later\n // Obviously, you want to reuse the factory to minimize overhead, so don't\n // do something stupid like instantiate a new factory in a loop.\n\n foreach (Type type in typeof(KeyValueToObjectFactory).Assembly.GetTypes())\n {\n if (type.IsSubclassOf(typeof(KVObjectBase)))\n {\n _kvTypes[type.Name.ToLower()] = type;\n }\n }\n }\n\n public KVObjectBase CreateObjectFromKV(KeyValuePair kv)\n {\n if (kv != null)\n {\n string kvName = kv.Key;\n\n // If the Type information is in our Dictionary, instantiate a new instance of that class.\n Type kvType;\n if (_kvTypes.TryGetValue(kvName, out kvType))\n {\n return (KVObjectBase)Activator.CreateInstance(kvType, kv.Value);\n }\n else\n {\n throw new ArgumentException(\"Unrecognized KV Pair\");\n }\n }\n else\n {\n return null;\n }\n }\n }\n\nA:\n\n@David:\nI already have the parser (and most of these will be hand written, so I decided against XML). But that looks like I really nice way of doing it; I'll have to check it out. Excellent point about versioning too. \n@Argelbargel:\nThat looks good too. :')\n\nA:\n\n...This is a fairly core piece of the\nproject I'm working on though...\n\nIs it really? \nIt's tempting to just abstract it and provide a basic implementation with the intention of refactoring later on.\nThen you can get on with what matters: the game.\nJust a thought\n\n\nA:\n\nIs it really?\n\nYes; I have thought this out. Far be it from me to do more work than neccessary. :') \n\n"},"title":{"kind":"string","value":"What is a good design when trying to build objects from a list of key value pairs?"},"question":{"kind":"string","value":"So if I have a method of parsing a text file and returning a list of a list of key value pairs, and want to create objects from the kvps returned (each list of kvps represents a different object), what would be the best method?\nThe first method that pops into mind is pretty simple, just keep a list of keywords:\nprivate const string NAME = \"name\";\nprivate const string PREFIX = \"prefix\";\n\nand check against the keys I get for the constants I want, defined above. This is a fairly core piece of the project I'm working on though, so I want to do it well; does anyone have any more robust suggestions (not saying there's anything inherently un-robust about the above method - I'm just asking around)?\nEdit:\nMore details have been asked for. I'm working on a little game in my spare time, and I am building up the game world with configuration files. There are four - one defines all creatures, another defines all areas (and their locations in a map), another all objects, and a final one defines various configuration options and things that don't fit else where. With the first three configuration files, I will be creating objects based on the content of the files - it will be quite text-heavy, so there will be a lot of strings, things like names, plurals, prefixes - that sort of thing. The configuration values are all like so:\n-\nkey: value \nkey: value\n-\nkey: value\nkey: value\n-\n\nWhere the '-' line denotes a new section/object.\n"},"answers":{"kind":"list like","value":["Take a deep look at the XmlSerializer. Even if you are constrained to not use XML on-disk, you might want to copy some of its features. This could then look like this:\npublic class DataObject {\n [Column(\"name\")]\n public string Name { get; set; }\n\n [Column(\"prefix\")]\n public string Prefix { get; set; }\n}\n\nBe careful though to include some kind of format version in your files, or you will be in hell's kitchen come the next format change.\n","Making a lot of unwarranted assumptions, I think that the best approach would be to create a Factory that will receive the list of key value pairs and return the proper object or throw an exception if it's invalid (or create a dummy object, or whatever is better in the particular case).\nprivate class Factory {\n\n public static IConfigurationObject Factory(List keyValuePair) {\n\n switch (keyValuePair[0]) {\n\n case \"x\":\n return new x(keyValuePair[1]);\n break;\n /* etc. */\n default:\n throw new ArgumentException(\"Wrong parameter in the file\");\n }\n\n }\n\n}\n\nThe strongest assumption here is that all your objects can be treated partly like the same (ie, they implement the same interface (IConfigurationObject in the example) or belong to the same inheritance tree).\nIf they don't, then it depends on your program flow and what are you doing with them. But nonetheless, they should :)\nEDIT: Given your explanation, you could have one Factory per file type, the switch in it would be the authoritative source on the allowed types per file type and they probably share something in common. Reflection is possible, but it's riskier because it's less obvious and self documenting than this one.\n","What do you need object for? The way you describe it, you'll use them as some kind (of key-wise) restricted map anyway. If you do not need some kind of inheritance, I'd simply wrap a map-like structure into a object like this:\n[java-inspired pseudo-code:]\nclass RestrictedKVDataStore {\n const ALLOWED_KEYS = new Collection('name', 'prefix');\n Map data = new Map();\n\n void put(String key, Object value) {\n if (ALLOWED_KEYS.contains(key))\n data.put(key, value)\n }\n\n Object get(String key) {\n return data.get(key);\n }\n}\n\n","You could create an interface that matched the column names, and then use the Reflection.Emit API to create a type at runtime that gave access to the data in the fields.\n","EDIT: \nScratch that, this still applies, but I think what your doing is reading a configuration file and parsing it into this:\nList>> itemConfig = \n new List>>();\n\nIn this case, we can still use a reflection factory to instantiate the objects, I'd just pass in the nested inner list to it, instead of passing each individual key/value pair.\nOLD POST:\nHere is a clever little way to do this using reflection:\nThe basic idea:\n\nUse a common base class for each Object class.\nPut all of these classes in their own assembly.\nPut this factory in that assembly too.\nPass in the KeyValuePair that you read from your config, and in return it finds the class that matches KV.Key and instantiates it with KV.Value\n\n \n public class KeyValueToObjectFactory\n { \n private Dictionary _kvTypes = new Dictionary();\n\n public KeyValueToObjectFactory()\n {\n // Preload the Types into a dictionary so we can look them up later\n // Obviously, you want to reuse the factory to minimize overhead, so don't\n // do something stupid like instantiate a new factory in a loop.\n\n foreach (Type type in typeof(KeyValueToObjectFactory).Assembly.GetTypes())\n {\n if (type.IsSubclassOf(typeof(KVObjectBase)))\n {\n _kvTypes[type.Name.ToLower()] = type;\n }\n }\n }\n\n public KVObjectBase CreateObjectFromKV(KeyValuePair kv)\n {\n if (kv != null)\n {\n string kvName = kv.Key;\n\n // If the Type information is in our Dictionary, instantiate a new instance of that class.\n Type kvType;\n if (_kvTypes.TryGetValue(kvName, out kvType))\n {\n return (KVObjectBase)Activator.CreateInstance(kvType, kv.Value);\n }\n else\n {\n throw new ArgumentException(\"Unrecognized KV Pair\");\n }\n }\n else\n {\n return null;\n }\n }\n }\n\n","@David:\nI already have the parser (and most of these will be hand written, so I decided against XML). But that looks like I really nice way of doing it; I'll have to check it out. Excellent point about versioning too. \n@Argelbargel:\nThat looks good too. :')\n","\n...This is a fairly core piece of the\nproject I'm working on though...\n\nIs it really? \nIt's tempting to just abstract it and provide a basic implementation with the intention of refactoring later on.\nThen you can get on with what matters: the game.\nJust a thought\n\n","\nIs it really?\n\nYes; I have thought this out. Far be it from me to do more work than neccessary. :') \n"],"string":"[\n \"Take a deep look at the XmlSerializer. Even if you are constrained to not use XML on-disk, you might want to copy some of its features. This could then look like this:\\npublic class DataObject {\\n [Column(\\\"name\\\")]\\n public string Name { get; set; }\\n\\n [Column(\\\"prefix\\\")]\\n public string Prefix { get; set; }\\n}\\n\\nBe careful though to include some kind of format version in your files, or you will be in hell's kitchen come the next format change.\\n\",\n \"Making a lot of unwarranted assumptions, I think that the best approach would be to create a Factory that will receive the list of key value pairs and return the proper object or throw an exception if it's invalid (or create a dummy object, or whatever is better in the particular case).\\nprivate class Factory {\\n\\n public static IConfigurationObject Factory(List keyValuePair) {\\n\\n switch (keyValuePair[0]) {\\n\\n case \\\"x\\\":\\n return new x(keyValuePair[1]);\\n break;\\n /* etc. */\\n default:\\n throw new ArgumentException(\\\"Wrong parameter in the file\\\");\\n }\\n\\n }\\n\\n}\\n\\nThe strongest assumption here is that all your objects can be treated partly like the same (ie, they implement the same interface (IConfigurationObject in the example) or belong to the same inheritance tree).\\nIf they don't, then it depends on your program flow and what are you doing with them. But nonetheless, they should :)\\nEDIT: Given your explanation, you could have one Factory per file type, the switch in it would be the authoritative source on the allowed types per file type and they probably share something in common. Reflection is possible, but it's riskier because it's less obvious and self documenting than this one.\\n\",\n \"What do you need object for? The way you describe it, you'll use them as some kind (of key-wise) restricted map anyway. If you do not need some kind of inheritance, I'd simply wrap a map-like structure into a object like this:\\n[java-inspired pseudo-code:]\\nclass RestrictedKVDataStore {\\n const ALLOWED_KEYS = new Collection('name', 'prefix');\\n Map data = new Map();\\n\\n void put(String key, Object value) {\\n if (ALLOWED_KEYS.contains(key))\\n data.put(key, value)\\n }\\n\\n Object get(String key) {\\n return data.get(key);\\n }\\n}\\n\\n\",\n \"You could create an interface that matched the column names, and then use the Reflection.Emit API to create a type at runtime that gave access to the data in the fields.\\n\",\n \"EDIT: \\nScratch that, this still applies, but I think what your doing is reading a configuration file and parsing it into this:\\nList>> itemConfig = \\n new List>>();\\n\\nIn this case, we can still use a reflection factory to instantiate the objects, I'd just pass in the nested inner list to it, instead of passing each individual key/value pair.\\nOLD POST:\\nHere is a clever little way to do this using reflection:\\nThe basic idea:\\n\\nUse a common base class for each Object class.\\nPut all of these classes in their own assembly.\\nPut this factory in that assembly too.\\nPass in the KeyValuePair that you read from your config, and in return it finds the class that matches KV.Key and instantiates it with KV.Value\\n\\n \\n public class KeyValueToObjectFactory\\n { \\n private Dictionary _kvTypes = new Dictionary();\\n\\n public KeyValueToObjectFactory()\\n {\\n // Preload the Types into a dictionary so we can look them up later\\n // Obviously, you want to reuse the factory to minimize overhead, so don't\\n // do something stupid like instantiate a new factory in a loop.\\n\\n foreach (Type type in typeof(KeyValueToObjectFactory).Assembly.GetTypes())\\n {\\n if (type.IsSubclassOf(typeof(KVObjectBase)))\\n {\\n _kvTypes[type.Name.ToLower()] = type;\\n }\\n }\\n }\\n\\n public KVObjectBase CreateObjectFromKV(KeyValuePair kv)\\n {\\n if (kv != null)\\n {\\n string kvName = kv.Key;\\n\\n // If the Type information is in our Dictionary, instantiate a new instance of that class.\\n Type kvType;\\n if (_kvTypes.TryGetValue(kvName, out kvType))\\n {\\n return (KVObjectBase)Activator.CreateInstance(kvType, kv.Value);\\n }\\n else\\n {\\n throw new ArgumentException(\\\"Unrecognized KV Pair\\\");\\n }\\n }\\n else\\n {\\n return null;\\n }\\n }\\n }\\n\\n\",\n \"@David:\\nI already have the parser (and most of these will be hand written, so I decided against XML). But that looks like I really nice way of doing it; I'll have to check it out. Excellent point about versioning too. \\n@Argelbargel:\\nThat looks good too. :')\\n\",\n \"\\n...This is a fairly core piece of the\\nproject I'm working on though...\\n\\nIs it really? \\nIt's tempting to just abstract it and provide a basic implementation with the intention of refactoring later on.\\nThen you can get on with what matters: the game.\\nJust a thought\\n\\n\",\n \"\\nIs it really?\\n\\nYes; I have thought this out. Far be it from me to do more work than neccessary. :') \\n\"\n]"},"answers_scores":{"kind":"list like","value":[3,3,2,1,1,0,0,0],"string":"[\n 3,\n 3,\n 2,\n 1,\n 1,\n 0,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["c#","key_value"],"string":"[\n \"c#\",\n \"key_value\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049757_c#_key_value.txt"}}},{"rowIdx":1584,"cells":{"content":{"kind":"string","value":"Q:\n\nSQL 2000 database copy to SQL 2005 options\n\nWe have a production web and database server with SQL Server 2000. (However, a few clients they have their own servers with SQL 2005.) So we have local installs of SQL 2005 Express for development on Windows XP SP3 boxes (which don't allow SQL 2000 Enterprise installations). \nWe often need to copy SQL 2000 databases to SQL 2005 instances. In the past, we have used the SQL Publishing tool (also mentioned here). However, one of our databases is so big that using that tool fails as it creates SQL scripts that get too large for Management Studio to handle them properly. Besides, it takes too long... :)\nWe would use the Copy Database Wizard included with SQL 2005, but our development machines run SQL 2005 Express which don't included SQL Server Agent, which is required for Copy Database Wizard to work. So, I guess our solution will be to upgrade our development installs with the full version of SQL 2005 (we have an MSDN subscription of course).\nI was wondering what other solutions, if any, work well for you guys? (Besides complaining to the bosses to upgrade our production servers to 2005 or even 2008--which I've already tried.)\n\nA:\n\nBack it up in SQL Server 2000 and then use the RESTORE WITH MOVE command into 2005 Express.\n\n"},"title":{"kind":"string","value":"SQL 2000 database copy to SQL 2005 options"},"question":{"kind":"string","value":"We have a production web and database server with SQL Server 2000. (However, a few clients they have their own servers with SQL 2005.) So we have local installs of SQL 2005 Express for development on Windows XP SP3 boxes (which don't allow SQL 2000 Enterprise installations). \nWe often need to copy SQL 2000 databases to SQL 2005 instances. In the past, we have used the SQL Publishing tool (also mentioned here). However, one of our databases is so big that using that tool fails as it creates SQL scripts that get too large for Management Studio to handle them properly. Besides, it takes too long... :)\nWe would use the Copy Database Wizard included with SQL 2005, but our development machines run SQL 2005 Express which don't included SQL Server Agent, which is required for Copy Database Wizard to work. So, I guess our solution will be to upgrade our development installs with the full version of SQL 2005 (we have an MSDN subscription of course).\nI was wondering what other solutions, if any, work well for you guys? (Besides complaining to the bosses to upgrade our production servers to 2005 or even 2008--which I've already tried.)\n"},"answers":{"kind":"list like","value":["Back it up in SQL Server 2000 and then use the RESTORE WITH MOVE command into 2005 Express.\n"],"string":"[\n \"Back it up in SQL Server 2000 and then use the RESTORE WITH MOVE command into 2005 Express.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[1],"string":"[\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["sql_server"],"string":"[\n \"sql_server\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050003_sql_server.txt"}}},{"rowIdx":1585,"cells":{"content":{"kind":"string","value":"Q:\n\nRegex to Match first 28 days of the month\n\nI am looking for a Regular expression to match only if a date is in the first 28 days of the month. This is for my validator control in ASP.NET\n\nA:\n\nDon't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead:\nDateTime parsedDate;\n\nif ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 )\n{\n // logic goes here.\n}\n\nRegex is nearly the golden hammer of input validation, but in this instance, it's the wrong choice.\n\nA:\n\nI don't think this is a task very well-suited for a regexp.\nI'd try and use the library functions (DateTime.Parse for .NET) to parse the date and then check the day component of it. Everything else is duplicating half the library function anyways.\n\nA:\n\nWhy not just covert it to a date data type and check the day? Using a regular expression, while it could be done, just makes it overly complicated.\n\nA:\n\n ([1-9]|1\\d|2[0-8]) // matches 1 to 28 but woudn't allow leading zeros for single digits\n(0?[1-9]|1\\d|2[0-8]) // matches 1 to 28 and would allow 01, 02,... 09\n\n(where \\d matches any digit, use [0-9] if your regex engine doesn't support it.)\nSee also the question What is the regex pattern for datetime (2008-09-01 12:35:45 ) ?\n\nA:\n\nI would use one of the DateTime.TryParse techniques in conjunction with a CustomValidator\n\n"},"title":{"kind":"string","value":"Regex to Match first 28 days of the month"},"question":{"kind":"string","value":"I am looking for a Regular expression to match only if a date is in the first 28 days of the month. This is for my validator control in ASP.NET\n"},"answers":{"kind":"list like","value":["Don't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead:\nDateTime parsedDate;\n\nif ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 )\n{\n // logic goes here.\n}\n\nRegex is nearly the golden hammer of input validation, but in this instance, it's the wrong choice.\n","I don't think this is a task very well-suited for a regexp.\nI'd try and use the library functions (DateTime.Parse for .NET) to parse the date and then check the day component of it. Everything else is duplicating half the library function anyways.\n","Why not just covert it to a date data type and check the day? Using a regular expression, while it could be done, just makes it overly complicated.\n"," ([1-9]|1\\d|2[0-8]) // matches 1 to 28 but woudn't allow leading zeros for single digits\n(0?[1-9]|1\\d|2[0-8]) // matches 1 to 28 and would allow 01, 02,... 09\n\n(where \\d matches any digit, use [0-9] if your regex engine doesn't support it.)\nSee also the question What is the regex pattern for datetime (2008-09-01 12:35:45 ) ?\n","I would use one of the DateTime.TryParse techniques in conjunction with a CustomValidator\n"],"string":"[\n \"Don't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead:\\nDateTime parsedDate;\\n\\nif ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 )\\n{\\n // logic goes here.\\n}\\n\\nRegex is nearly the golden hammer of input validation, but in this instance, it's the wrong choice.\\n\",\n \"I don't think this is a task very well-suited for a regexp.\\nI'd try and use the library functions (DateTime.Parse for .NET) to parse the date and then check the day component of it. Everything else is duplicating half the library function anyways.\\n\",\n \"Why not just covert it to a date data type and check the day? Using a regular expression, while it could be done, just makes it overly complicated.\\n\",\n \" ([1-9]|1\\\\d|2[0-8]) // matches 1 to 28 but woudn't allow leading zeros for single digits\\n(0?[1-9]|1\\\\d|2[0-8]) // matches 1 to 28 and would allow 01, 02,... 09\\n\\n(where \\\\d matches any digit, use [0-9] if your regex engine doesn't support it.)\\nSee also the question What is the regex pattern for datetime (2008-09-01 12:35:45 ) ?\\n\",\n \"I would use one of the DateTime.TryParse techniques in conjunction with a CustomValidator\\n\"\n]"},"answers_scores":{"kind":"list like","value":[18,2,1,1,1],"string":"[\n 18,\n 2,\n 1,\n 1,\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["asp.net","regex"],"string":"[\n \"asp.net\",\n \"regex\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049919_asp.net_regex.txt"}}},{"rowIdx":1586,"cells":{"content":{"kind":"string","value":"Q:\n\nIn what order are locations searched to load referenced DLLs?\n\nI know that the .NET framework looks for referenced DLLs in several locations\n\nGlobal assembly cache (GAC)\nAny private paths added to the AppDomain\nThe current directory of the executing assembly\n\nWhat order are those locations searched? Is the search for a DLL ceased if a match is found or does it continue through all locations (and if so, how are conflicts resolved)?\nAlso, please confirm or deny those locations and provide any other locations I have failed to mention.\n\nA:\n\nAssembly loading is a rather elaborate process which depends on lots of different factors like configuration files, publisher policies, appdomain settings, CLR hosts, partial or full assembly names, etc.\nThe simple version is that the GAC is first, then the private paths. %PATH% is never used.\nIt is best to use Assembly Binding Log Viewer (Fuslogvw.exe) to debug any assembly loading problems.\nEDIT\nHow the Runtime Locates Assemblies explains the process in more detail.\n\nA:\n\nI found an article referencing the MSDN article on DLL search order that says\n\nFor managed code dependencies, the\n Global Assembly Cache always prevails;\n the local assembly in application\n directory will not be picked up if\n there is an existing (or newer with\n policy) copy in the GAC.\n\nConsidering this, I guess the MSDN list is correct with one addition\n0. Global assembly cache\n\nA:\n\nNo longer is the current directory searched first when loading DLLs! This change was also made in Windows XP SP1. The default behavior now is to look in all the system locations first, then the current directory, and finally any user-defined paths.\n\n(ref. http://weblogs.asp.net/pwilson/archive/2003/06/24/9214.aspx)\nThe default search order, which can be changed by the application, is also described on MSDN: Dynamic-Link Library Search Order.\n\n"},"title":{"kind":"string","value":"In what order are locations searched to load referenced DLLs?"},"question":{"kind":"string","value":"I know that the .NET framework looks for referenced DLLs in several locations\n\nGlobal assembly cache (GAC)\nAny private paths added to the AppDomain\nThe current directory of the executing assembly\n\nWhat order are those locations searched? Is the search for a DLL ceased if a match is found or does it continue through all locations (and if so, how are conflicts resolved)?\nAlso, please confirm or deny those locations and provide any other locations I have failed to mention.\n"},"answers":{"kind":"list like","value":["Assembly loading is a rather elaborate process which depends on lots of different factors like configuration files, publisher policies, appdomain settings, CLR hosts, partial or full assembly names, etc.\nThe simple version is that the GAC is first, then the private paths. %PATH% is never used.\nIt is best to use Assembly Binding Log Viewer (Fuslogvw.exe) to debug any assembly loading problems.\nEDIT\nHow the Runtime Locates Assemblies explains the process in more detail.\n","I found an article referencing the MSDN article on DLL search order that says\n\nFor managed code dependencies, the\n Global Assembly Cache always prevails;\n the local assembly in application\n directory will not be picked up if\n there is an existing (or newer with\n policy) copy in the GAC.\n\nConsidering this, I guess the MSDN list is correct with one addition\n0. Global assembly cache\n","\nNo longer is the current directory searched first when loading DLLs! This change was also made in Windows XP SP1. The default behavior now is to look in all the system locations first, then the current directory, and finally any user-defined paths.\n\n(ref. http://weblogs.asp.net/pwilson/archive/2003/06/24/9214.aspx)\nThe default search order, which can be changed by the application, is also described on MSDN: Dynamic-Link Library Search Order.\n"],"string":"[\n \"Assembly loading is a rather elaborate process which depends on lots of different factors like configuration files, publisher policies, appdomain settings, CLR hosts, partial or full assembly names, etc.\\nThe simple version is that the GAC is first, then the private paths. %PATH% is never used.\\nIt is best to use Assembly Binding Log Viewer (Fuslogvw.exe) to debug any assembly loading problems.\\nEDIT\\nHow the Runtime Locates Assemblies explains the process in more detail.\\n\",\n \"I found an article referencing the MSDN article on DLL search order that says\\n\\nFor managed code dependencies, the\\n Global Assembly Cache always prevails;\\n the local assembly in application\\n directory will not be picked up if\\n there is an existing (or newer with\\n policy) copy in the GAC.\\n\\nConsidering this, I guess the MSDN list is correct with one addition\\n0. Global assembly cache\\n\",\n \"\\nNo longer is the current directory searched first when loading DLLs! This change was also made in Windows XP SP1. The default behavior now is to look in all the system locations first, then the current directory, and finally any user-defined paths.\\n\\n(ref. http://weblogs.asp.net/pwilson/archive/2003/06/24/9214.aspx)\\nThe default search order, which can be changed by the application, is also described on MSDN: Dynamic-Link Library Search Order.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[57,7,2],"string":"[\n 57,\n 7,\n 2\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":[".net","dll"],"string":"[\n \".net\",\n \"dll\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000049972_.net_dll.txt"}}},{"rowIdx":1587,"cells":{"content":{"kind":"string","value":"Q:\n\nIs Visual Studio 2003 still available/supported\n\nPretty much what the title says really.\nWe have some code that is .NET 1.1 based and no real desire to up-convert it. However, we are looking to add developers to the team and they will need copies of Visual Studio.\nMy understanding is that they will need VS 2003 - as this is the only IDE that supports .NET 1.1 but I am wondering if we are still able to purchase it!\n\nA:\n\nYou can build 1.1 projects in Visual Studio 2005:\nhttp://www.hanselman.com/blog/BuildingNET11ProjectsUsingVisualStudio2005.aspx\nThe MSBuild Everett Environment (MSBEE) has been announced, and soon this will be a (reasonably) supported scenario and we'll all be able to build both 1.1 and 2.0 versions of .NET code on Visual Studio 2005. \nAlso read this post about this issue:\nhttp://blogs.msdn.com/clichten/archive/2005/11/08/490541.aspx\nAnd also:\nMSBuild Extras – Toolkit for .NET 1.1 “MSBee” is an addition to MSBuild that allows developers to build managed applications using Visual Studio 2005 projects that target .NET 1.1. \n\nA:\n\nVisual Studio 2003 is still available to download for MSDN subscribers.\nThe EULA for Visual Studio includes a 'downgrade' clause, which appears, IMNAL, to allow you to buy Visual Studio 2008 and then install 2003 under the same license.\n\nDOWNGRADE. You may install and use\n this version and an earlier version of\n the software at the same time. This\n agreement applies to your use of the\n earlier version. If the earlier\n version includes different components,\n any terms for those components in the\n agreement that comes with the earlier\n version apply to your use of them.\n Microsoft is not obligated to supply\n earlier versions to you.\n\nA:\n\nMainstream support for VS2003 ends in October of this year:\nhttp://support.microsoft.com/lifecycle/search/?sort=PN&alpha=Visual+Studio\nExtended support (whatever that means) is still available for quite some time.\n\nA:\n\nIn addition to Espo's link, look into MSBee, an enhancements kit for MSBuild to better support .NET Framework 1.1.\nIt seems you can even use .NET 1.1 with Visual Studio 2008, though, so you should have no problem.\nThat said, I'd be interested in hearing what made you choose against upgrading.\n\nA:\n\nSupported: Yes\nAvailable: Not through normal channels. You might still find a boxed copy on Amazon or somewhere.\n\nA:\n\n.NET 1.1 code can be imported in VS 2005, as .NET 2.0 is backward compatible with .NET 1.1.\nYou'll probably have to convert the project, but it should still run in VS 2005.\n\nA:\n\nI believe that vs2003 looses support in october\n\n"},"title":{"kind":"string","value":"Is Visual Studio 2003 still available/supported"},"question":{"kind":"string","value":"Pretty much what the title says really.\nWe have some code that is .NET 1.1 based and no real desire to up-convert it. However, we are looking to add developers to the team and they will need copies of Visual Studio.\nMy understanding is that they will need VS 2003 - as this is the only IDE that supports .NET 1.1 but I am wondering if we are still able to purchase it!\n"},"answers":{"kind":"list like","value":["You can build 1.1 projects in Visual Studio 2005:\nhttp://www.hanselman.com/blog/BuildingNET11ProjectsUsingVisualStudio2005.aspx\nThe MSBuild Everett Environment (MSBEE) has been announced, and soon this will be a (reasonably) supported scenario and we'll all be able to build both 1.1 and 2.0 versions of .NET code on Visual Studio 2005. \nAlso read this post about this issue:\nhttp://blogs.msdn.com/clichten/archive/2005/11/08/490541.aspx\nAnd also:\nMSBuild Extras – Toolkit for .NET 1.1 “MSBee” is an addition to MSBuild that allows developers to build managed applications using Visual Studio 2005 projects that target .NET 1.1. \n","Visual Studio 2003 is still available to download for MSDN subscribers.\nThe EULA for Visual Studio includes a 'downgrade' clause, which appears, IMNAL, to allow you to buy Visual Studio 2008 and then install 2003 under the same license.\n\nDOWNGRADE. You may install and use\n this version and an earlier version of\n the software at the same time. This\n agreement applies to your use of the\n earlier version. If the earlier\n version includes different components,\n any terms for those components in the\n agreement that comes with the earlier\n version apply to your use of them.\n Microsoft is not obligated to supply\n earlier versions to you.\n\n","Mainstream support for VS2003 ends in October of this year:\nhttp://support.microsoft.com/lifecycle/search/?sort=PN&alpha=Visual+Studio\nExtended support (whatever that means) is still available for quite some time.\n","In addition to Espo's link, look into MSBee, an enhancements kit for MSBuild to better support .NET Framework 1.1.\nIt seems you can even use .NET 1.1 with Visual Studio 2008, though, so you should have no problem.\nThat said, I'd be interested in hearing what made you choose against upgrading.\n","Supported: Yes\nAvailable: Not through normal channels. You might still find a boxed copy on Amazon or somewhere.\n",".NET 1.1 code can be imported in VS 2005, as .NET 2.0 is backward compatible with .NET 1.1.\nYou'll probably have to convert the project, but it should still run in VS 2005.\n","I believe that vs2003 looses support in october\n"],"string":"[\n \"You can build 1.1 projects in Visual Studio 2005:\\nhttp://www.hanselman.com/blog/BuildingNET11ProjectsUsingVisualStudio2005.aspx\\nThe MSBuild Everett Environment (MSBEE) has been announced, and soon this will be a (reasonably) supported scenario and we'll all be able to build both 1.1 and 2.0 versions of .NET code on Visual Studio 2005. \\nAlso read this post about this issue:\\nhttp://blogs.msdn.com/clichten/archive/2005/11/08/490541.aspx\\nAnd also:\\nMSBuild Extras – Toolkit for .NET 1.1 “MSBee” is an addition to MSBuild that allows developers to build managed applications using Visual Studio 2005 projects that target .NET 1.1. \\n\",\n \"Visual Studio 2003 is still available to download for MSDN subscribers.\\nThe EULA for Visual Studio includes a 'downgrade' clause, which appears, IMNAL, to allow you to buy Visual Studio 2008 and then install 2003 under the same license.\\n\\nDOWNGRADE. You may install and use\\n this version and an earlier version of\\n the software at the same time. This\\n agreement applies to your use of the\\n earlier version. If the earlier\\n version includes different components,\\n any terms for those components in the\\n agreement that comes with the earlier\\n version apply to your use of them.\\n Microsoft is not obligated to supply\\n earlier versions to you.\\n\\n\",\n \"Mainstream support for VS2003 ends in October of this year:\\nhttp://support.microsoft.com/lifecycle/search/?sort=PN&alpha=Visual+Studio\\nExtended support (whatever that means) is still available for quite some time.\\n\",\n \"In addition to Espo's link, look into MSBee, an enhancements kit for MSBuild to better support .NET Framework 1.1.\\nIt seems you can even use .NET 1.1 with Visual Studio 2008, though, so you should have no problem.\\nThat said, I'd be interested in hearing what made you choose against upgrading.\\n\",\n \"Supported: Yes\\nAvailable: Not through normal channels. You might still find a boxed copy on Amazon or somewhere.\\n\",\n \".NET 1.1 code can be imported in VS 2005, as .NET 2.0 is backward compatible with .NET 1.1.\\nYou'll probably have to convert the project, but it should still run in VS 2005.\\n\",\n \"I believe that vs2003 looses support in october\\n\"\n]"},"answers_scores":{"kind":"list like","value":[8,8,2,1,0,0,0],"string":"[\n 8,\n 8,\n 2,\n 1,\n 0,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":[".net","visual_studio","visual_studio_2003"],"string":"[\n \".net\",\n \"visual_studio\",\n \"visual_studio_2003\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050046_.net_visual_studio_visual_studio_2003.txt"}}},{"rowIdx":1588,"cells":{"content":{"kind":"string","value":"Q:\n\nWhat are some good SharePoint security resources?\n\nI've got a SharePoint application and I'm sad to say that in my SharePoint-induced excitement, I ignored a lot of the security concerns I should have been paying more attention to. Though we didn't before, now we actually need granular security, so I need to get educated. I'm mostly interested in how to best create groups and add users to those groups. We have a single main site collection and a couple dozen subsites under that collection. How can I best create a granular security world where I can independently assign rights to each of these subsites?\n\nA:\n\nTo have permissions vary at the \"sub site\" level which is the SPWeb object in object model terms you need to enable unique permission for the site.\nA good article outlining the permission hierarchy in SharePoint 2007 can be found on the office web site About controlling access to sites and site content\n\nIn my experience if you are able to use permission inheritance over granular security it's much less hassle to manage.\nBreaking site permission inheritance\n\nClick \"People and groups\"\nClick \"Site permissions\"\nFrom the actions menu in the list click \"Edit Permissions\"\n\nhttp://blog.richfinn.net/content/binary/WindowsLiveWriter/InstallandConfiguretheCommunityKitforSha_E660/image_3.png http://blog.richfinn.net/content/binary/WindowsLiveWriter/InstallandConfiguretheCommunityKitforSha_E660/image_3.png\nOther references\n\nSharePoint 2007: Permissions, permissions, permissions.\nSharePoint 2007 SiteGroups - part 1 - the basics \n\n"},"title":{"kind":"string","value":"What are some good SharePoint security resources?"},"question":{"kind":"string","value":"I've got a SharePoint application and I'm sad to say that in my SharePoint-induced excitement, I ignored a lot of the security concerns I should have been paying more attention to. Though we didn't before, now we actually need granular security, so I need to get educated. I'm mostly interested in how to best create groups and add users to those groups. We have a single main site collection and a couple dozen subsites under that collection. How can I best create a granular security world where I can independently assign rights to each of these subsites?\n"},"answers":{"kind":"list like","value":["To have permissions vary at the \"sub site\" level which is the SPWeb object in object model terms you need to enable unique permission for the site.\nA good article outlining the permission hierarchy in SharePoint 2007 can be found on the office web site About controlling access to sites and site content\n\nIn my experience if you are able to use permission inheritance over granular security it's much less hassle to manage.\nBreaking site permission inheritance\n\nClick \"People and groups\"\nClick \"Site permissions\"\nFrom the actions menu in the list click \"Edit Permissions\"\n\nhttp://blog.richfinn.net/content/binary/WindowsLiveWriter/InstallandConfiguretheCommunityKitforSha_E660/image_3.png http://blog.richfinn.net/content/binary/WindowsLiveWriter/InstallandConfiguretheCommunityKitforSha_E660/image_3.png\nOther references\n\nSharePoint 2007: Permissions, permissions, permissions.\nSharePoint 2007 SiteGroups - part 1 - the basics \n\n"],"string":"[\n \"To have permissions vary at the \\\"sub site\\\" level which is the SPWeb object in object model terms you need to enable unique permission for the site.\\nA good article outlining the permission hierarchy in SharePoint 2007 can be found on the office web site About controlling access to sites and site content\\n\\nIn my experience if you are able to use permission inheritance over granular security it's much less hassle to manage.\\nBreaking site permission inheritance\\n\\nClick \\\"People and groups\\\"\\nClick \\\"Site permissions\\\"\\nFrom the actions menu in the list click \\\"Edit Permissions\\\"\\n\\nhttp://blog.richfinn.net/content/binary/WindowsLiveWriter/InstallandConfiguretheCommunityKitforSha_E660/image_3.png http://blog.richfinn.net/content/binary/WindowsLiveWriter/InstallandConfiguretheCommunityKitforSha_E660/image_3.png\\nOther references\\n\\nSharePoint 2007: Permissions, permissions, permissions.\\nSharePoint 2007 SiteGroups - part 1 - the basics \\n\\n\"\n]"},"answers_scores":{"kind":"list like","value":[5],"string":"[\n 5\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["security","sharepoint"],"string":"[\n \"security\",\n \"sharepoint\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050037_security_sharepoint.txt"}}},{"rowIdx":1589,"cells":{"content":{"kind":"string","value":"Q:\n\nAre there any negative reasons to use an N-Tier solution?\n\nI'm pretty new to my company (2 weeks) and we're starting a new platform for our system using .NET 3.5 Team Foundation from DotNetNuke. Our \"architect\" is suggesting we use one class project. Of course, I chime back with a \"3-tier\" architecture (Business, Data, Web class projects). \nIs there any disadvantages to using this architecture? Pro's would be separation of code from data, keeping class objects away from your code, etc.\n\nA:\n\nI guess a fairly big downside is that the extra volume of code that you have to write, manage and maintain for a small project may just be overkill.\nIt's all down to what's appropriate for the size of the project, the expected life of the final project and the budget! Sometimes, whilst doing things 'properly' is appealing, doing something a little more 'lightweight' can be the right commercial decision!\n\nA:\n\nit tends to take an inexperienced team longer to build 3-tier.It's more code, so more bugs. I'm just playing the devil's advocate though.\n\nA:\n\nI would be pushing hard for the N tiered approach even if it's a small project. If you use an ORM tool like codesmith + nettiers you will be able to quickly setup the projects and be developing code that solves your business problems quickly.\nIt kills me when you start a new project and you spend days sitting around spinning wheels talking about how the \"architecture\" should be architected. You want to be spending time solving the business problem, not solving problems that other people have solved for you. Using an ORM (it doesn't really matter which one, just pick one and stick to it) to help you get initial traction will help keep you focussed on the goals of the project and not distract you trying to solve \"architecture\" issues.\nIf, at the end of the day, the architect wants to go the one project approach, there is no reason you can't create an app_code folder with a BLL and DAL folder to seperate the code for now which will help you move to an N-Tiered solution later.\n\nA:\n\nBecause you want the capability of being able to distribute the layers onto different physical tiers (I always use \"tier\" for physical, and \"layer\" for logical), you should think twice before just putting everything into one class because you've got major refactorings to do if or when you do need to start distributing.\n\nA:\n\nThe only disadvantage is complexity but really how hard is it to add some domain objects and bind to a list of them as opposed to using a dataset. You don't even have to create three seperate projects, you can just create 3 seperate folders within the web app and give each one a namespace like, YourCompany.YourApp.Domain, YourCompany.YourApp.Data, etc. \nThe big advantage is having a more flexible solution. If you start writing your app as a data centric application, strongly coupling your web forms pages to datasets, you are going to end up doing a lot more work later migrating to a more domain centeric model as your business logic grows in complexity. \nMaybe in the short term you focus on a simple solution by creating very simple domain objects and populating them from datasets, then you can add business logic to them as needed and build out a more sophisticated ORM as needed, or use nhibernate.\n\nA:\n\nAs with anything abstraction creates complexity, and so the complexity of doing N-tiered should be properly justified, e.g., does N-tiered actually benefit the system? There will be small systems that will work best with N-tiered, although a lot of them will not.\nAlso, even if your system is small at the moment, you might want to add more features to it later -- not going N-tiered might consitute a sort of technical debt on your part, so you have to be careful.\n\n"},"title":{"kind":"string","value":"Are there any negative reasons to use an N-Tier solution?"},"question":{"kind":"string","value":"I'm pretty new to my company (2 weeks) and we're starting a new platform for our system using .NET 3.5 Team Foundation from DotNetNuke. Our \"architect\" is suggesting we use one class project. Of course, I chime back with a \"3-tier\" architecture (Business, Data, Web class projects). \nIs there any disadvantages to using this architecture? Pro's would be separation of code from data, keeping class objects away from your code, etc.\n"},"answers":{"kind":"list like","value":["I guess a fairly big downside is that the extra volume of code that you have to write, manage and maintain for a small project may just be overkill.\nIt's all down to what's appropriate for the size of the project, the expected life of the final project and the budget! Sometimes, whilst doing things 'properly' is appealing, doing something a little more 'lightweight' can be the right commercial decision!\n","it tends to take an inexperienced team longer to build 3-tier.It's more code, so more bugs. I'm just playing the devil's advocate though.\n","I would be pushing hard for the N tiered approach even if it's a small project. If you use an ORM tool like codesmith + nettiers you will be able to quickly setup the projects and be developing code that solves your business problems quickly.\nIt kills me when you start a new project and you spend days sitting around spinning wheels talking about how the \"architecture\" should be architected. You want to be spending time solving the business problem, not solving problems that other people have solved for you. Using an ORM (it doesn't really matter which one, just pick one and stick to it) to help you get initial traction will help keep you focussed on the goals of the project and not distract you trying to solve \"architecture\" issues.\nIf, at the end of the day, the architect wants to go the one project approach, there is no reason you can't create an app_code folder with a BLL and DAL folder to seperate the code for now which will help you move to an N-Tiered solution later.\n","Because you want the capability of being able to distribute the layers onto different physical tiers (I always use \"tier\" for physical, and \"layer\" for logical), you should think twice before just putting everything into one class because you've got major refactorings to do if or when you do need to start distributing.\n","The only disadvantage is complexity but really how hard is it to add some domain objects and bind to a list of them as opposed to using a dataset. You don't even have to create three seperate projects, you can just create 3 seperate folders within the web app and give each one a namespace like, YourCompany.YourApp.Domain, YourCompany.YourApp.Data, etc. \nThe big advantage is having a more flexible solution. If you start writing your app as a data centric application, strongly coupling your web forms pages to datasets, you are going to end up doing a lot more work later migrating to a more domain centeric model as your business logic grows in complexity. \nMaybe in the short term you focus on a simple solution by creating very simple domain objects and populating them from datasets, then you can add business logic to them as needed and build out a more sophisticated ORM as needed, or use nhibernate.\n","As with anything abstraction creates complexity, and so the complexity of doing N-tiered should be properly justified, e.g., does N-tiered actually benefit the system? There will be small systems that will work best with N-tiered, although a lot of them will not.\nAlso, even if your system is small at the moment, you might want to add more features to it later -- not going N-tiered might consitute a sort of technical debt on your part, so you have to be careful.\n"],"string":"[\n \"I guess a fairly big downside is that the extra volume of code that you have to write, manage and maintain for a small project may just be overkill.\\nIt's all down to what's appropriate for the size of the project, the expected life of the final project and the budget! Sometimes, whilst doing things 'properly' is appealing, doing something a little more 'lightweight' can be the right commercial decision!\\n\",\n \"it tends to take an inexperienced team longer to build 3-tier.It's more code, so more bugs. I'm just playing the devil's advocate though.\\n\",\n \"I would be pushing hard for the N tiered approach even if it's a small project. If you use an ORM tool like codesmith + nettiers you will be able to quickly setup the projects and be developing code that solves your business problems quickly.\\nIt kills me when you start a new project and you spend days sitting around spinning wheels talking about how the \\\"architecture\\\" should be architected. You want to be spending time solving the business problem, not solving problems that other people have solved for you. Using an ORM (it doesn't really matter which one, just pick one and stick to it) to help you get initial traction will help keep you focussed on the goals of the project and not distract you trying to solve \\\"architecture\\\" issues.\\nIf, at the end of the day, the architect wants to go the one project approach, there is no reason you can't create an app_code folder with a BLL and DAL folder to seperate the code for now which will help you move to an N-Tiered solution later.\\n\",\n \"Because you want the capability of being able to distribute the layers onto different physical tiers (I always use \\\"tier\\\" for physical, and \\\"layer\\\" for logical), you should think twice before just putting everything into one class because you've got major refactorings to do if or when you do need to start distributing.\\n\",\n \"The only disadvantage is complexity but really how hard is it to add some domain objects and bind to a list of them as opposed to using a dataset. You don't even have to create three seperate projects, you can just create 3 seperate folders within the web app and give each one a namespace like, YourCompany.YourApp.Domain, YourCompany.YourApp.Data, etc. \\nThe big advantage is having a more flexible solution. If you start writing your app as a data centric application, strongly coupling your web forms pages to datasets, you are going to end up doing a lot more work later migrating to a more domain centeric model as your business logic grows in complexity. \\nMaybe in the short term you focus on a simple solution by creating very simple domain objects and populating them from datasets, then you can add business logic to them as needed and build out a more sophisticated ORM as needed, or use nhibernate.\\n\",\n \"As with anything abstraction creates complexity, and so the complexity of doing N-tiered should be properly justified, e.g., does N-tiered actually benefit the system? There will be small systems that will work best with N-tiered, although a lot of them will not.\\nAlso, even if your system is small at the moment, you might want to add more features to it later -- not going N-tiered might consitute a sort of technical debt on your part, so you have to be careful.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[9,3,2,2,1,0],"string":"[\n 9,\n 3,\n 2,\n 2,\n 1,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["architecture","n_tier_architecture"],"string":"[\n \"architecture\",\n \"n_tier_architecture\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000005880_architecture_n_tier_architecture.txt"}}},{"rowIdx":1590,"cells":{"content":{"kind":"string","value":"Q:\n\nA good algorithm similar to Levenshtein but weighted for Qwerty keyboards?\n\nI noticed some posts here on string matching, which reminded me of an old problem I'd like to solve. Does anyone have a good Levenshtein-like algorithm that is weighted toward Qwerty keyboards?\nI want to compare two strings, and and allow for typos. Levenshtein is okay, but I'd prefer to also accept spelling errors based on the physical distance between keys on Qwerty keyboard. In other words, the algorithm should prefer \"yelephone\" to \"zelephone\" since the \"y\" key is located nearer to the \"t\" key than to the \"z\" key on most keyboards.\nAny help would be great... this feature isn't central to my project, so I don't want to veer off into a rat-hole when I should be doing something more productive.\n\nA:\n\nIn bioinformatics when you align two sequences of DNA you might have a model that has a different cost based on if the substitution is a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 matrix or some, dare I say distance function? So the cost of a replacement is from the matrix/function, not a constant. \nCAVEAT: Be sure that deletions and insertions are weighted properly though, so they aren't over accepted as the minimum. You'll end up with a string of insertions/deletions/no-change-substitution characters. \nThe new function you are trying to minimize would be:\nd[i, j] := minimum(\n d[i-1, j] + del_cost,\n d[i, j-1] + ins_cost,\n d[i-1, j-1] + keyboard_distance( s[i], t[j] )\n)\n\n"},"title":{"kind":"string","value":"A good algorithm similar to Levenshtein but weighted for Qwerty keyboards?"},"question":{"kind":"string","value":"I noticed some posts here on string matching, which reminded me of an old problem I'd like to solve. Does anyone have a good Levenshtein-like algorithm that is weighted toward Qwerty keyboards?\nI want to compare two strings, and and allow for typos. Levenshtein is okay, but I'd prefer to also accept spelling errors based on the physical distance between keys on Qwerty keyboard. In other words, the algorithm should prefer \"yelephone\" to \"zelephone\" since the \"y\" key is located nearer to the \"t\" key than to the \"z\" key on most keyboards.\nAny help would be great... this feature isn't central to my project, so I don't want to veer off into a rat-hole when I should be doing something more productive.\n"},"answers":{"kind":"list like","value":["In bioinformatics when you align two sequences of DNA you might have a model that has a different cost based on if the substitution is a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 matrix or some, dare I say distance function? So the cost of a replacement is from the matrix/function, not a constant. \nCAVEAT: Be sure that deletions and insertions are weighted properly though, so they aren't over accepted as the minimum. You'll end up with a string of insertions/deletions/no-change-substitution characters. \nThe new function you are trying to minimize would be:\nd[i, j] := minimum(\n d[i-1, j] + del_cost,\n d[i, j-1] + ins_cost,\n d[i-1, j-1] + keyboard_distance( s[i], t[j] )\n)\n\n"],"string":"[\n \"In bioinformatics when you align two sequences of DNA you might have a model that has a different cost based on if the substitution is a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 matrix or some, dare I say distance function? So the cost of a replacement is from the matrix/function, not a constant. \\nCAVEAT: Be sure that deletions and insertions are weighted properly though, so they aren't over accepted as the minimum. You'll end up with a string of insertions/deletions/no-change-substitution characters. \\nThe new function you are trying to minimize would be:\\nd[i, j] := minimum(\\n d[i-1, j] + del_cost,\\n d[i, j-1] + ins_cost,\\n d[i-1, j-1] + keyboard_distance( s[i], t[j] )\\n)\\n\\n\"\n]"},"answers_scores":{"kind":"list like","value":[20],"string":"[\n 20\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["algorithm","comparison","string","text"],"string":"[\n \"algorithm\",\n \"comparison\",\n \"string\",\n \"text\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050144_algorithm_comparison_string_text.txt"}}},{"rowIdx":1591,"cells":{"content":{"kind":"string","value":"Q:\n\nWhat is the best way to display a status message in WPF?\n\nI have several wpf pages with update/delete/add buttons. I want to display to the user messages like \"successful delete\", etc. How can I best implement this so the message is defined in a single place (similar to an asp.net master page) and I can update this message from anywhere?\n\nA:\n\nYou may want to consider doing a publish/subscribe (\"Observer\" pattern) -- define a \"status changed\" event on a base page, and create a custom control that sets up a delegate and event handler to listen for status updates.\nThen you could drop the custom control on any page that inherits from the base, and it would automatically listen for and display status messages whenever the event is fired.\nEdit: I put together a sample implementation of this pattern and published a blog post walking through the code.\n\nA:\n\nI don't think you have the ASP.Net master pages translated to the WPF Page world just yet.\nA workaround till MS gets there, I would probably put a Control at the top of the page (or wherever) that just displays a particular User-level \"Application Setting\". You can update the string property like\nMyAppUserSettings.StatusMessage = \"You just deleted the administrator!\" \n\nCrude but will get the job done I think!\n\n"},"title":{"kind":"string","value":"What is the best way to display a status message in WPF?"},"question":{"kind":"string","value":"I have several wpf pages with update/delete/add buttons. I want to display to the user messages like \"successful delete\", etc. How can I best implement this so the message is defined in a single place (similar to an asp.net master page) and I can update this message from anywhere?\n"},"answers":{"kind":"list like","value":["You may want to consider doing a publish/subscribe (\"Observer\" pattern) -- define a \"status changed\" event on a base page, and create a custom control that sets up a delegate and event handler to listen for status updates.\nThen you could drop the custom control on any page that inherits from the base, and it would automatically listen for and display status messages whenever the event is fired.\nEdit: I put together a sample implementation of this pattern and published a blog post walking through the code.\n","I don't think you have the ASP.Net master pages translated to the WPF Page world just yet.\nA workaround till MS gets there, I would probably put a Control at the top of the page (or wherever) that just displays a particular User-level \"Application Setting\". You can update the string property like\nMyAppUserSettings.StatusMessage = \"You just deleted the administrator!\" \n\nCrude but will get the job done I think!\n"],"string":"[\n \"You may want to consider doing a publish/subscribe (\\\"Observer\\\" pattern) -- define a \\\"status changed\\\" event on a base page, and create a custom control that sets up a delegate and event handler to listen for status updates.\\nThen you could drop the custom control on any page that inherits from the base, and it would automatically listen for and display status messages whenever the event is fired.\\nEdit: I put together a sample implementation of this pattern and published a blog post walking through the code.\\n\",\n \"I don't think you have the ASP.Net master pages translated to the WPF Page world just yet.\\nA workaround till MS gets there, I would probably put a Control at the top of the page (or wherever) that just displays a particular User-level \\\"Application Setting\\\". You can update the string property like\\nMyAppUserSettings.StatusMessage = \\\"You just deleted the administrator!\\\" \\n\\nCrude but will get the job done I think!\\n\"\n]"},"answers_scores":{"kind":"list like","value":[4,1],"string":"[\n 4,\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["wpf"],"string":"[\n \"wpf\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050151_wpf.txt"}}},{"rowIdx":1592,"cells":{"content":{"kind":"string","value":"Q:\n\nHow can I lock down my MS-SQL DB from my users and yet still access it through ODBC?\n\nI've got an ms-access application that's accessing and ms-sql db through an ODBC connection. I'm trying to force my users to update the data only through the application portion, but I don't care if they read the data directly or through their own custom ms-access db (they use it for creating ad hoc reports).\nWhat I'm looking for is a way to make the data only editable if they are using the compiled .mde file I distribute to them. I know I can make the data read only for the general population, and editable for select users. \nIs there a way I can get ms-sql to make the data editable only if they are accessing it through the my canned mde?\nThought, is there a way to get ms-access to log into the database as a different user (or change the login once connected)?\n\n@Jake,\nYes, it's using forms. What I'm looking to do is just have it switch users once when I have my launchpad/mainmenu form pop up.\n@Peter,\nThat is indeed the direction I'm headed. What I haven't determined was how to go about switching to that second ID. I'm not so worried about the password being sniffed, the users are all internal, and on an internal LAN. If they can sniff that password, they can certainly sniff the one for my privileged ID.\n@no one in general,\nRight now its security by obscurity. I've given the uses a special .mdb for doing reporting that will let them read data, but not update it. They don't know about relinking to the tables through the ODBC connection. A slightly more ms-access/DB literate user could by pass what I've done in seconds - and there a few who imagine themselves to be DBA, so they will figure it out eventually.\n\nA:\n\nThere is a way to do this that is effective with internal users, but can be hacked. You create two IDs for each user. One is a reporting ID that has read-only access. This is they ID that the user knows about: Fred / mypassword\nThe second is an ID that can do updates. That id is Fred_app / mypassword_mangled. They log on to your app with Fred. When your application accesses data, it uses the application id.\nThis can be sniffed, but for many applications it is sufficient.\n\nA:\n\nDoes you app allow for linked table updates or does it go through forms? Sounds like your idea of using a centralized user with distinct roles is the way to go. Yes, you could change users but I that may introduce more coding and once you start adding more and more code other solutions (stored procedures, etc) may sound more inviting. \n\n"},"title":{"kind":"string","value":"How can I lock down my MS-SQL DB from my users and yet still access it through ODBC?"},"question":{"kind":"string","value":"I've got an ms-access application that's accessing and ms-sql db through an ODBC connection. I'm trying to force my users to update the data only through the application portion, but I don't care if they read the data directly or through their own custom ms-access db (they use it for creating ad hoc reports).\nWhat I'm looking for is a way to make the data only editable if they are using the compiled .mde file I distribute to them. I know I can make the data read only for the general population, and editable for select users. \nIs there a way I can get ms-sql to make the data editable only if they are accessing it through the my canned mde?\nThought, is there a way to get ms-access to log into the database as a different user (or change the login once connected)?\n\n@Jake,\nYes, it's using forms. What I'm looking to do is just have it switch users once when I have my launchpad/mainmenu form pop up.\n@Peter,\nThat is indeed the direction I'm headed. What I haven't determined was how to go about switching to that second ID. I'm not so worried about the password being sniffed, the users are all internal, and on an internal LAN. If they can sniff that password, they can certainly sniff the one for my privileged ID.\n@no one in general,\nRight now its security by obscurity. I've given the uses a special .mdb for doing reporting that will let them read data, but not update it. They don't know about relinking to the tables through the ODBC connection. A slightly more ms-access/DB literate user could by pass what I've done in seconds - and there a few who imagine themselves to be DBA, so they will figure it out eventually.\n"},"answers":{"kind":"list like","value":["There is a way to do this that is effective with internal users, but can be hacked. You create two IDs for each user. One is a reporting ID that has read-only access. This is they ID that the user knows about: Fred / mypassword\nThe second is an ID that can do updates. That id is Fred_app / mypassword_mangled. They log on to your app with Fred. When your application accesses data, it uses the application id.\nThis can be sniffed, but for many applications it is sufficient.\n","Does you app allow for linked table updates or does it go through forms? Sounds like your idea of using a centralized user with distinct roles is the way to go. Yes, you could change users but I that may introduce more coding and once you start adding more and more code other solutions (stored procedures, etc) may sound more inviting. \n"],"string":"[\n \"There is a way to do this that is effective with internal users, but can be hacked. You create two IDs for each user. One is a reporting ID that has read-only access. This is they ID that the user knows about: Fred / mypassword\\nThe second is an ID that can do updates. That id is Fred_app / mypassword_mangled. They log on to your app with Fred. When your application accesses data, it uses the application id.\\nThis can be sniffed, but for many applications it is sufficient.\\n\",\n \"Does you app allow for linked table updates or does it go through forms? Sounds like your idea of using a centralized user with distinct roles is the way to go. Yes, you could change users but I that may introduce more coding and once you start adding more and more code other solutions (stored procedures, etc) may sound more inviting. \\n\"\n]"},"answers_scores":{"kind":"list like","value":[2,1],"string":"[\n 2,\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["ms_access","odbc","sql_server"],"string":"[\n \"ms_access\",\n \"odbc\",\n \"sql_server\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050164_ms_access_odbc_sql_server.txt"}}},{"rowIdx":1593,"cells":{"content":{"kind":"string","value":"Q:\n\nDoes \"display: marker\" work in any current browsers, and if so, how?\n\nI can't be sure if my code is sucking, or if it's just that the browsers haven't caught up with the spec yet.\nMy goal is to simulate list markers using generated content, so as to get e.g. continuation of the counters from list to list in pure CSS.\nSo the code below, which I think is correct according to the spec, is like this:\n\nhtml {\r\n counter-reset: myCounter;\r\n}\r\nli {\r\n counter-increment: myCounter;\r\n}\r\nli:before {\r\n content: counter(myCounter)\". \";\r\n display: marker;\r\n width: 5em;\r\n text-align: right;\r\n marker-offset: 1em;\r\n}\n
    \r\n
  1. The
  2. \r\n
  3. quick
  4. \r\n
  5. brown
  6. \r\n
\r\n
    \r\n
  1. fox
  2. \r\n
  3. jumped
  4. \r\n
  5. over
  6. \r\n
\n\nBut this doesn't seem to generate markers, in either FF3, Chrome, or IE8 beta 2, and if I recall correctly not Opera either (although I've since uninstalled Opera).\nSo, does anyone know if markers are supposed to work? Quirksmode.org isn't being its usual helpful self in this regard :(.\n\nA:\n\nApparently marker was introduced as a value in CSS 2 but did not make it to CSS 2.1 because of lacking browser support.\nI suppose that didn’t help its popularity …\nSource: http://de.selfhtml.org/css/eigenschaften/positionierung.htm#display (German)\n\nA:\n\nOh ouch, did not know that :-|. That probably seals its case, then. Because mostly I was under the assumption that such a basic CSS2 property should definitely be supported in modern browsers, but if it didn't make it into CSS 2.1, then it makes a lot more sense that it isn't.\nFor future reference, it doesn't show up in the Mozilla Development Center, so presumably Firefox doesn't support it at all.\nAlso for future reference, I got my original example to work with inline-block instead:\nli:before\n{\n content: counter(myCounter)\". \";\n display: inline-block;\n width: 2em;\n padding-right: 0.3em;\n text-align: right;\n}\n\n"},"title":{"kind":"string","value":"Does \"display: marker\" work in any current browsers, and if so, how?"},"question":{"kind":"string","value":"I can't be sure if my code is sucking, or if it's just that the browsers haven't caught up with the spec yet.\nMy goal is to simulate list markers using generated content, so as to get e.g. continuation of the counters from list to list in pure CSS.\nSo the code below, which I think is correct according to the spec, is like this:\n\n\nhtml {\r\n counter-reset: myCounter;\r\n}\r\nli {\r\n counter-increment: myCounter;\r\n}\r\nli:before {\r\n content: counter(myCounter)\". \";\r\n display: marker;\r\n width: 5em;\r\n text-align: right;\r\n marker-offset: 1em;\r\n}\n
    \r\n
  1. The
  2. \r\n
  3. quick
  4. \r\n
  5. brown
  6. \r\n
\r\n
    \r\n
  1. fox
  2. \r\n
  3. jumped
  4. \r\n
  5. over
  6. \r\n
\n\n\n\nBut this doesn't seem to generate markers, in either FF3, Chrome, or IE8 beta 2, and if I recall correctly not Opera either (although I've since uninstalled Opera).\nSo, does anyone know if markers are supposed to work? Quirksmode.org isn't being its usual helpful self in this regard :(.\n"},"answers":{"kind":"list like","value":["Apparently marker was introduced as a value in CSS 2 but did not make it to CSS 2.1 because of lacking browser support.\nI suppose that didn’t help its popularity …\nSource: http://de.selfhtml.org/css/eigenschaften/positionierung.htm#display (German)\n","Oh ouch, did not know that :-|. That probably seals its case, then. Because mostly I was under the assumption that such a basic CSS2 property should definitely be supported in modern browsers, but if it didn't make it into CSS 2.1, then it makes a lot more sense that it isn't.\nFor future reference, it doesn't show up in the Mozilla Development Center, so presumably Firefox doesn't support it at all.\nAlso for future reference, I got my original example to work with inline-block instead:\nli:before\n{\n content: counter(myCounter)\". \";\n display: inline-block;\n width: 2em;\n padding-right: 0.3em;\n text-align: right;\n}\n\n"],"string":"[\n \"Apparently marker was introduced as a value in CSS 2 but did not make it to CSS 2.1 because of lacking browser support.\\nI suppose that didn’t help its popularity …\\nSource: http://de.selfhtml.org/css/eigenschaften/positionierung.htm#display (German)\\n\",\n \"Oh ouch, did not know that :-|. That probably seals its case, then. Because mostly I was under the assumption that such a basic CSS2 property should definitely be supported in modern browsers, but if it didn't make it into CSS 2.1, then it makes a lot more sense that it isn't.\\nFor future reference, it doesn't show up in the Mozilla Development Center, so presumably Firefox doesn't support it at all.\\nAlso for future reference, I got my original example to work with inline-block instead:\\nli:before\\n{\\n content: counter(myCounter)\\\". \\\";\\n display: inline-block;\\n width: 2em;\\n padding-right: 0.3em;\\n text-align: right;\\n}\\n\\n\"\n]"},"answers_scores":{"kind":"list like","value":[3,1],"string":"[\n 3,\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["cross_browser","css"],"string":"[\n \"cross_browser\",\n \"css\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050170_cross_browser_css.txt"}}},{"rowIdx":1594,"cells":{"content":{"kind":"string","value":"Q:\n\nView of allocated memory\n\nI'm looking for a tool ($, free, open source; I don't care) that will allow me to view not just the memory statistics for a .NET program, but also the object hierarchy. I'd really like to be able to drill down each thourgh each object and view it's foot print, as well as all the object's it references.\nI've looked at things like Ants Profiler from RedGate, but it's not quite what I want: I can't view specific instances.\nEDIT:\nI've used the .NET Memory Profiler (the one that ships with visual studio, and the one that used to be part of the SDK (?))before, and while it's really good (and shows views most other don't), what I'm really after is being able to drill down through my object hierarchy, viewing each object instance.\n\nA:\n\nI have used JetBrains DotTrace and Redgate Ants, both of which I would recommend. A lesser known profiler I have also used is .Net Memory Profiler (http://memprofiler.com/), which at the time I used it provided a different perspective on memory usage than the former two profilers mentioned. I find DotTrace and Ants to be very similar, though each one is slightly different.\n\nA:\n\nJetBrains dottrace profiler is the best. I wouldn't work without it. It is hard to find a tool that is free and performs well in this arena. Dottrace is hands down the best profiler I have used for .Net.\n\nA:\n\nThere's also the Microsoft .net profiler - I've used it a bit, and it's not bad for a free tool. Not sure if you can walk the object hierarchy, but does break down memory use by type, and over time. You can even see the underlying data.\nIt does slow down the app a lot, though.\n\n"},"title":{"kind":"string","value":"View of allocated memory"},"question":{"kind":"string","value":"I'm looking for a tool ($, free, open source; I don't care) that will allow me to view not just the memory statistics for a .NET program, but also the object hierarchy. I'd really like to be able to drill down each thourgh each object and view it's foot print, as well as all the object's it references.\nI've looked at things like Ants Profiler from RedGate, but it's not quite what I want: I can't view specific instances.\nEDIT:\nI've used the .NET Memory Profiler (the one that ships with visual studio, and the one that used to be part of the SDK (?))before, and while it's really good (and shows views most other don't), what I'm really after is being able to drill down through my object hierarchy, viewing each object instance.\n"},"answers":{"kind":"list like","value":["I have used JetBrains DotTrace and Redgate Ants, both of which I would recommend. A lesser known profiler I have also used is .Net Memory Profiler (http://memprofiler.com/), which at the time I used it provided a different perspective on memory usage than the former two profilers mentioned. I find DotTrace and Ants to be very similar, though each one is slightly different.\n","JetBrains dottrace profiler is the best. I wouldn't work without it. It is hard to find a tool that is free and performs well in this arena. Dottrace is hands down the best profiler I have used for .Net.\n","There's also the Microsoft .net profiler - I've used it a bit, and it's not bad for a free tool. Not sure if you can walk the object hierarchy, but does break down memory use by type, and over time. You can even see the underlying data.\nIt does slow down the app a lot, though.\n"],"string":"[\n \"I have used JetBrains DotTrace and Redgate Ants, both of which I would recommend. A lesser known profiler I have also used is .Net Memory Profiler (http://memprofiler.com/), which at the time I used it provided a different perspective on memory usage than the former two profilers mentioned. I find DotTrace and Ants to be very similar, though each one is slightly different.\\n\",\n \"JetBrains dottrace profiler is the best. I wouldn't work without it. It is hard to find a tool that is free and performs well in this arena. Dottrace is hands down the best profiler I have used for .Net.\\n\",\n \"There's also the Microsoft .net profiler - I've used it a bit, and it's not bad for a free tool. Not sure if you can walk the object hierarchy, but does break down memory use by type, and over time. You can even see the underlying data.\\nIt does slow down the app a lot, though.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[5,0,0],"string":"[\n 5,\n 0,\n 0\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":[".net","memory"],"string":"[\n \".net\",\n \"memory\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050237_.net_memory.txt"}}},{"rowIdx":1595,"cells":{"content":{"kind":"string","value":"Q:\n\nAre there any issues with using log4net in a multi-threaded environment?\n\nI'm wondering if anyone has any experience using log4net in a multi-threaded environment like asp.net. We are currently using log4net and I want to make sure we won't run into any issues.\n\nA:\n\nWe run log4net (and log4cxx) in highly multi-threaded environments without issue. You will want to be careful how you configure them though.\nThe issue with log4net that Jeff describes pertains to the use of a certain appender. We stick with simple log file appenders on the whole to reduce the impact of logging on the operation of the code. Writing a line to a file is pretty minimal, kicking off another database transaction is very heavy.\n\n"},"title":{"kind":"string","value":"Are there any issues with using log4net in a multi-threaded environment?"},"question":{"kind":"string","value":"I'm wondering if anyone has any experience using log4net in a multi-threaded environment like asp.net. We are currently using log4net and I want to make sure we won't run into any issues.\n"},"answers":{"kind":"list like","value":["We run log4net (and log4cxx) in highly multi-threaded environments without issue. You will want to be careful how you configure them though.\nThe issue with log4net that Jeff describes pertains to the use of a certain appender. We stick with simple log file appenders on the whole to reduce the impact of logging on the operation of the code. Writing a line to a file is pretty minimal, kicking off another database transaction is very heavy.\n"],"string":"[\n \"We run log4net (and log4cxx) in highly multi-threaded environments without issue. You will want to be careful how you configure them though.\\nThe issue with log4net that Jeff describes pertains to the use of a certain appender. We stick with simple log file appenders on the whole to reduce the impact of logging on the operation of the code. Writing a line to a file is pretty minimal, kicking off another database transaction is very heavy.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[1],"string":"[\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":["log4net"],"string":"[\n \"log4net\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050213_log4net.txt"}}},{"rowIdx":1596,"cells":{"content":{"kind":"string","value":"Q:\n\n.MSI Not Always Uninstalling Previous Versions\n\nIn a number of applications we create an MSI Installer with the Visual Studio Setup Project. In most cases, the install works fine, but every now and then the previous version was not uninstalled correctly. The user ends up with two icons on the desktop, and in the Add/Remove program list, the application appears twice. We have yet to find any pattern and in most cases the installer works without any problems.\n\nA:\n\nWhat happens when the uninstall of the previous version fails depends on the sequencing of the RemoveExistingProducts action. I have written a summary about the various options in the past: http://jpassing.wordpress.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/.\nUnfortunately, you do not have control over RemoveExistingProducts sequencing when using VS setup projects (Unless you edit the MSI with Orca after it has been built, which usually is not practical). But if your setup project is not completely trivial, I would strongly suggest you to use a different MSI authoring tool like WiX or one of the commercial tools anyway.\n\n"},"title":{"kind":"string","value":".MSI Not Always Uninstalling Previous Versions"},"question":{"kind":"string","value":"In a number of applications we create an MSI Installer with the Visual Studio Setup Project. In most cases, the install works fine, but every now and then the previous version was not uninstalled correctly. The user ends up with two icons on the desktop, and in the Add/Remove program list, the application appears twice. We have yet to find any pattern and in most cases the installer works without any problems.\n"},"answers":{"kind":"list like","value":["What happens when the uninstall of the previous version fails depends on the sequencing of the RemoveExistingProducts action. I have written a summary about the various options in the past: http://jpassing.wordpress.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/.\nUnfortunately, you do not have control over RemoveExistingProducts sequencing when using VS setup projects (Unless you edit the MSI with Orca after it has been built, which usually is not practical). But if your setup project is not completely trivial, I would strongly suggest you to use a different MSI authoring tool like WiX or one of the commercial tools anyway.\n"],"string":"[\n \"What happens when the uninstall of the previous version fails depends on the sequencing of the RemoveExistingProducts action. I have written a summary about the various options in the past: http://jpassing.wordpress.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/.\\nUnfortunately, you do not have control over RemoveExistingProducts sequencing when using VS setup projects (Unless you edit the MSI with Orca after it has been built, which usually is not practical). But if your setup project is not completely trivial, I would strongly suggest you to use a different MSI authoring tool like WiX or one of the commercial tools anyway.\\n\"\n]"},"answers_scores":{"kind":"list like","value":[1],"string":"[\n 1\n]"},"non_answers":{"kind":"list like","value":[],"string":"[]"},"non_answers_scores":{"kind":"list like","value":[],"string":"[]"},"tags":{"kind":"list like","value":[".net","windows_installer"],"string":"[\n \".net\",\n \"windows_installer\"\n]"},"name":{"kind":"string","value":"stackoverflow_0000050268_.net_windows_installer.txt"}}},{"rowIdx":1597,"cells":{"content":{"kind":"string","value":"Q:\n\nFloats messing up in Safari browsers\n\nI have a site I made really fast that uses floats to display different sections of content. The floated content and the content that has an additional margin both appear fine in FF/IE, but on safari one of the divs is completely hidden. I've tried switching to padding and position:relative, but nothing has worked for me. If I take out the code to display it to the right it shows up again but under the floated content.\nThe main section of css that seems to be causing the problem is:\n#settings{\n float:left;\n}\n\n#right_content{\n margin-top:20px;\n margin-left:440px;\n width:400px;\n}\n\nThis gives me the same result whether I specify a size to the #settings div or not. Any ideas would be appreciated.\nThe site is available at: http://frickinsweet.com/tools/Theme.mvc.aspx to see the source code.\n\nA:\n\nHave you tried floating the #right_content div to the right?\n#right_content{\n float: right;\n margin-top: 20px;\n width: 400px;\n}\n\nA:\n\nI believe the error lies in the mark up that the color picker is generating. I saved the page and removed that code for the color picker and it renders fine in IE/FF/SF. \n\nA:\n\nSorry I should have mentioned that as well. I tried floating that content right and additionally tried floating it left and setting the position with the thinking that both divs would start out at left:0 where setting the margin of the right would move it over.\nThanks\n\nA:\n\nA few things you should fix beforehand:\n\nYour