The Bosque programming language is designed for writing code that is simple, obvious, and easy to reason about for both humans and machines. The key design features of the language provide ways to avoidaccidental complexity in the development and coding process. The goal is improved developer productivity, increased software quality, and enabling a range of new compilers and developer tooling experiences.
Metadata Function ها در SQL Server
To be able to make full use of the system catalog to find out more about a database, you need to be familiar with the metadata functions. They save a great deal of time and typing when querying the metadata. Once you get the hang of these functions, the system catalog suddenly seems simple to use, as Robert Sheldon demonstrates in this article.
نتایج GitHub Octoverse 2021
public void MsInteropReplace(Microsoft.Office.Interop.Word.Application doc, object findText, object replaceWithText) { object matchCase = false; object matchWholeWord = true; object matchWildCards = false; object matchSoundsLike = false; object matchAllWordForms = false; object forward = true; object format = false; object matchKashida = false; object matchDiacritics = false; object matchAlefHamza = false; object matchControl = false; object read_only = false; object visible = true; object replace = 2; object wrap = 1; //execute find and replace doc.Selection.Find.Execute(ref findText, ref matchCase, ref matchWholeWord, ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap, ref format, ref replaceWithText, ref replace, ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl); }
private static void MsInteropReplace2() { var doc = new Microsoft.Office.Interop.Word.Application().Documents.Open(@"D:\temp\te1.docx"); doc.Content.Find.Execute("@levelOrder", false, true, false, false, false, true, 1, false, "12345", 2, false, false, false, false); object missing = System.Reflection.Missing.Value; doc.SaveAs(@"D:\temp\out.docx", ref missing, ref missing, ref missing, ref missing , ref missing, ref missing, ref missing, ref missing, ref missing, ref missing , ref missing, ref missing, ref missing, ref missing, ref missing); }
که هر دو مورد را در stackoverflow میتوانید پیدا کنید. به شخصه از این مورد برای replace کردن مقادیر در یک فایل template.docx استفاده میکردم؛ ولی بعد از مدتی فهمیدم که Footerها و Header را نمیتواند پردازش کند. کد زیر در تمامی قسمتهایی که در یک فایل word میتوان متغیر تعریف کرد را گشته و عمل پر کردن مقادیر را بر روی فایل نمونه، انجام میدهد و شامل سه متد ذیل است:
private static void repAll() { object Missing = System.Reflection.Missing.Value; Application app = null; Microsoft.Office.Interop.Word.Document doc = null; try { app = new Microsoft.Office.Interop.Word.Application(); doc = app.Documents.Open(@"D:\temp\te1.docx", Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing); FindReplaceAnywhere(app, "@levelOrder", "محرمانه"); doc.SaveAs(@"D:\temp\out.docx", Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing); } finally { try { if (doc != null) ((Microsoft.Office.Interop.Word._Document)doc).Close(true, Missing, Missing); } finally { } if (app != null) ((Microsoft.Office.Interop.Word._Application)app).Quit(true, Missing, Missing); } } private static void searchAndReplaceInStory(Microsoft.Office.Interop.Word.Range rngStory, string strSearch, string strReplace) { rngStory.Find.ClearFormatting(); rngStory.Find.Replacement.ClearFormatting(); rngStory.Find.Text = strSearch; rngStory.Find.Replacement.Text = strReplace; rngStory.Find.Wrap = WdFindWrap.wdFindContinue; object Missing = System.Reflection.Missing.Value; object arg1 = Missing; // Find Pattern object arg2 = Missing; //MatchCase object arg3 = Missing; //MatchWholeWord object arg4 = Missing; //MatchWildcards object arg5 = Missing; //MatchSoundsLike object arg6 = Missing; //MatchAllWordForms object arg7 = Missing; //Forward object arg8 = Missing; //Wrap object arg9 = Missing; //Format object arg10 = Missing; //ReplaceWith object arg11 = WdReplace.wdReplaceAll; //Replace object arg12 = Missing; //MatchKashida object arg13 = Missing; //MatchDiacritics object arg14 = Missing; //MatchAlefHamza object arg15 = Missing; //MatchControl rngStory.Find.Execute(ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6, ref arg7, ref arg8, ref arg9, ref arg10, ref arg11, ref arg12, ref arg13, ref arg14, ref arg15); } // Main routine to find text and replace it, // var app = new Microsoft.Office.Interop.Word.Application(); public static void FindReplaceAnywhere(Microsoft.Office.Interop.Word.Application app, string findText, string replaceText) { // http://forums.asp.net/p/1501791/3739871.aspx var doc = app.ActiveDocument; // Fix the skipped blank Header/Footer problem // http://msdn.microsoft.com/en-us/library/aa211923(office.11).aspx Microsoft.Office.Interop.Word.WdStoryType lngJunk = doc.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.StoryType; // Iterate through all story types in the current document foreach (Microsoft.Office.Interop.Word.Range rngStory in doc.StoryRanges) { // Iterate through all linked stories var internalRangeStory = rngStory; do { searchAndReplaceInStory(internalRangeStory, findText, replaceText); try { // 6 , 7 , 8 , 9 , 10 , 11 -- http://msdn.microsoft.com/en-us/library/aa211923(office.11).aspx switch (internalRangeStory.StoryType) { case Microsoft.Office.Interop.Word.WdStoryType.wdEvenPagesHeaderStory: // 6 case Microsoft.Office.Interop.Word.WdStoryType.wdPrimaryHeaderStory: // 7 case Microsoft.Office.Interop.Word.WdStoryType.wdEvenPagesFooterStory: // 8 case Microsoft.Office.Interop.Word.WdStoryType.wdPrimaryFooterStory: // 9 case Microsoft.Office.Interop.Word.WdStoryType.wdFirstPageHeaderStory: // 10 case Microsoft.Office.Interop.Word.WdStoryType.wdFirstPageFooterStory: // 11 if (internalRangeStory.ShapeRange.Count > 0) { foreach (Microsoft.Office.Interop.Word.Shape oShp in internalRangeStory.ShapeRange) { if (oShp.TextFrame.HasText != 0) { searchAndReplaceInStory(oShp.TextFrame.TextRange, findText, replaceText); } } } break; default: break; } } catch { // On Error Resume Next } // ON ERROR GOTO 0 -- http://www.harding.edu/fmccown/vbnet_csharp_comparison.html // Get next linked story (if any) internalRangeStory = internalRangeStory.NextStoryRange; } while (internalRangeStory != null); // http://www.harding.edu/fmccown/vbnet_csharp_comparison.html } }
برای تهیه pdf نیز میتوانید به کد زیر مراجعه کنید:
public static void getFileDocxInPdf() { // Create a new Microsoft Word application object Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); // C# doesn't have optional arguments so we'll need a dummy value object oMissing = System.Reflection.Missing.Value; // Get list of Word files in specified directory DirectoryInfo dirInfo = new DirectoryInfo(@"D:\temp"); FileInfo[] wordFiles = dirInfo.GetFiles("*.docx"); word.Visible = false; word.ScreenUpdating = false; foreach (FileInfo wordFile in wordFiles) { // Cast as Object for word Open method Object filename = (Object)wordFile.FullName; // Use the dummy value as a placeholder for optional arguments Microsoft.Office.Interop.Word.Document doc = word.Documents.Open(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); doc.Activate(); object outputFileName = wordFile.FullName.Replace(".docx", ".pdf"); object fileFormat = WdSaveFormat.wdFormatPDF; // Save document into PDF Format doc.SaveAs(ref outputFileName, ref fileFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); // Close the Word document, but leave the Word application open. // doc has to be cast to type _Document so that it will find the // correct Close method. object saveChanges = WdSaveOptions.wdDoNotSaveChanges; ((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing); doc = null; } // word has to be cast to type _Application so that it will find // the correct Quit method. ((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing); word = null; }
برای شناسایی ایرادات در کد و بهبود کیفیت کدها میتوانید از ابزارهای دستهی lint استفاده کنید که تعدادی از معروفترین این ابزارها (jslint ,cpplint ,eslint ,nodelint و ...) هستند.
برای نصب چنین ابزاری مثل lint میتوانید به شکل زیر آن را نصب کنید:
npm install -g eslint
برای اولین بار نیاز است که آماده سازی ابتدایی برای این کتابخانه صورت بگیرد که با دستور زیر قابل انجام است:
eslint --init
? How would you like to configure ESLint? Answer questions about your style ? Are you using ECMAScript 6 features? Yes ? Are you using ES6 modules? Yes ? Where will your code run? Browser, Node ? Do you use CommonJS? No ? Do you use JSX? No ? What style of indentation do you use? Spaces ? What quotes do you use for strings? Double ? What line endings do you use? Windows ? Do you require semicolons? Yes ? What format do you want your config file to be in? JSON Successfully created .eslintrc.json file in D:\ali\electron
eslint . یا eslint index.js
میتوانید این دستور را در در خصوصیت test، در بخش اسکریپت، به شکل زیر وارد کنید:
{ "name": "electron", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "electron .", "test":"eslint ." }, "author": "", "license": "ISC" }
npm test
D:\ali\electron\index.js 1:26 error Strings must use doublequote quotes 16:8 error Strings must use doublequote quotes 19:3 error Expected indentation of 4 space characters but found 2 indent 22:3 error Expected indentation of 4 space characters but found 2 indent ✖ 4 problems (4 errors, 0 warnings)
برای نامگذاری فایلهای js، به جای استفاده از _ از - استفاده کنید. این قاعدهای است که گیت هاب در نامگذاری فایلهای js انجام میدهد. یعنی به جای عبارت dotnet_tips.js از عبارت dotnet-tips.js استفاده کنید. خاطرتان جمع باشد که هیچ فایل جاوااسکرپیتی رسمی در الکترون، خارج از این قاعده نامگذاری نشده است.
سعی کنید از جدیدترین قواعد موجود در ES6 استفاده کنید مانند:
let برای تعریف متغیرها
const برای تعریف ثابت ها
توابع جهتی به جای نوشتن عبارت function
استفاده از template stringها به جای چسباندن رشتهها از طریق عملگر +
برای نامگذاری متغیرها از همان قوانین تعریف شده برای node.js استفاده کنید که شامل موارد زیر است:
- موقعی که یک ماژول را به عنوان یک کلاس استفاده میکنید از متد CamelCase استفاده کنید مثل BrowserWindow
- موقعی که از یک ماژول که حاوی مجموعهای از دستورات و apiها است استفاده میکنید، از قانون mixedCase استفاده کنید مثل app یا globalShortcut
- موقعی که یک api به عنوان خصوصیت یک شیء مورد استفاده قرار میگیرد، از mixedCase استفاده کنید؛ به عنوان مثال win.webContents یا fs.readFileSync
- برای مابقی اشیا مثل دستورات process و یا تگ webview که به شکل متفاوتتری مورد استفاده قرار میگیرند، از همان عنوانهای خودشان استفاده میکنیم.
موقعی که api جدیدی را میسازید و قصد تعریف متدی را دارید بهتر است دو متد برای get و set تعریف شود، نسبت به حالتی که در کتابخانه جی کوئری مورد استفاده قرار میگیرد یعنی عبارتهای زیر
setText('test'); getText();
.text([text]);
بررسی Virtual events در #C
نکات جالبی درباره Breakpoints
Have you ever found a bug in your code and wanted to pause code execution to inspect the problem? If you are a developer, there’s a strong chance you have experienced or will experience this issue many, many times. While the short and sweet answer to this problem is to use a breakpoint, the longer answer is that Visual Studio actually provides multiple kinds of breakpoints and methods that let you pause your code depending on the context! Based on the different scenarios you may experience while debugging, here are some of the various ways to pause your code and set or manage a breakpoint in Visual Studio 2017
آموزش 2 ساعته روش کار با Postman
"Learn Postman in One Video: Master the API Testing Tool" is an engaging and comprehensive Udemy course designed to take you from a beginner to a proficient user of Postman. In this concise and focused course, you will learn everything you need to know about Postman, the popular API testing and development tool.