a habit tracker app that is free to use on 6 platforms: Web browser, Windows, Linux, Android, iOS and macOS. Approximately 98% of the programming code is the same for all 6 platforms. There are 3 different projects that use the shared code: - a Blazor WASM project for the PWA - a MAUI Blazor project for Windows, Android, iOS and macOS - a Photino Blazor project for Linux
اشتراکها
خلاصه ASP.NET vNext در 4 دقیقه
- Project format is changing to a single JSON file
- ASP.NET MVC and Web API have been unified into a single programming model
- Project Roslyn allows for a “no-compile” developer experience while making updates
- Migration to a OWIN hosting model allows for flexibility in production web hosts (IIS or running on Linux via Mono)
مطالب
آموزش TypeScript #3
در این پست به تشریح انواع داده در زبان TypeScript و ذکر مثال در این زمینه میپردازیم.
تعریف متغیرها و انواع داده
در TypeScript هنگام تعریف متغیرها باید نوع داده ای آنها را مشخص کنیم. در TypeScript پنج نوع داده ای وجود دارد که در زیر با ذکر مثال تعریف شده اند. مفاهیم ماژول، کلاس و تابع در پست بعدی به تشریح توضیح داده خواهند شد.
number : معادل نوع داده ای number در JavaScript است. برای ذخیره سازی اعداد صحیح و اعشاری استفاده میشود.
یک مثال:
حال باید یک فایل Html برای استفاده از این کلاس داشته باشیم. به صورت زیر:
بعد از اجرای پروزه خروجی به صورت زیر خواهد بود:
string : معادل نوع داده ای رشته ای است و برای ذخیره سازی مجموعه ای از کاراکترها از نوع UTF-16 استفاده میشود.
یک مثال:
کد کامپایل شده و تبدیل آن به JavaScript:
خروجی به صورت زیر است:
boolean: برای ذخیره سازی مقادیر true یا false میباشد.
مثال:
کد کامپایل شده و تبدیل آن به JavaScript:
null: همانند دات نت هنگامی که قصد داشته باشیم مقدار یک متغیر را null اختصاص دهیم از این کلمه کلیدی استفاده میکنیم.
مثال:
کد کامپایل شده و تبدیل آن به JavaScript:
undefined:معادل نوع undefined در Javascript است. اگر به یک متغیر مقدار اختصاص ندهید مقدار آن undefined خواهد بود.
مثال:
کد کامپایل شده و تبدیل آن به JavaScript:
خروجی این مثال نیز به صورت زیر است:
ادامه دارد...
تعریف متغیرها و انواع داده
در TypeScript هنگام تعریف متغیرها باید نوع داده ای آنها را مشخص کنیم. در TypeScript پنج نوع داده ای وجود دارد که در زیر با ذکر مثال تعریف شده اند. مفاهیم ماژول، کلاس و تابع در پست بعدی به تشریح توضیح داده خواهند شد.
number : معادل نوع داده ای number در JavaScript است. برای ذخیره سازی اعداد صحیح و اعشاری استفاده میشود.
یک مثال:
class NumberTypeOfTypeScript { MyFunction() { var p: number; p = 1; var q = 2; var r = 3.33; alert("Value of P=" + p + " Value of q=" + q + " Value of r=" + r); } } window.onload = () =>{ var value = new NumberTypeOfTypeScript(); value.MyFunction(); }
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>TypeScript HTML App</title> <link rel="stylesheet" href="app.css" type="text/css" /> <script src="app.js"></script> </head> <body> <h1>Number Type in TypeScript</h1> <div id="content"/> </body> </html>
string : معادل نوع داده ای رشته ای است و برای ذخیره سازی مجموعه ای از کاراکترها از نوع UTF-16 استفاده میشود.
یک مثال:
class StringTypeOfTypeScript { Myfunction() { var s: string; s="TypeScript" var empty = ""; var abc = "abc"; alert("Value of s="+ s+" Empty string="+ empty+" Value of abc ="+abc) ; } } window.onload = () =>{ var value = new StringTypeOfTypeScript(); value.Myfunction(); }
var StringTypeOfTypeScript = (function () { function StringTypeOfTypeScript() { } StringTypeOfTypeScript.prototype.Myfunction = function () { var s; s = "TypeScript"; var empty = ""; var abc = "abc"; alert("Value of s=" + s + " Empty string=" + empty + " Value of abc =" + abc); }; return StringTypeOfTypeScript; })(); window.onload = function () { var value = new StringTypeOfTypeScript(); value.Myfunction(); };
boolean: برای ذخیره سازی مقادیر true یا false میباشد.
مثال:
class booleanTypeofTypeScript { MyFunction() { var lie: bool; lie = false; var a = 12; if (typeof (lie) == "boolean" && typeof (a) == "boolean") { alert("Both is boolean type"); } if (typeof (lie) == "boolean" && typeof (a) != "boolean") { alert("lie is boolean type and a is not!") } else { alert("a is boolean type and lie is not!"); } } } window.onload =()=> { var access = new booleanTypeofTypeScript(); access.MyFunction(); }
var booleanTypeofTypeScript = (function () { function booleanTypeofTypeScript() { } booleanTypeofTypeScript.prototype.MyFunction = function () { var lie; lie = false; var a = 12; if(typeof (lie) == "boolean" && typeof (a) == "boolean") { alert("Both is boolean type"); } if(typeof (lie) == "boolean" && typeof (a) != "boolean") { alert("lie is boolean type and a is not!"); } else { alert("a is boolean type and lie is not!"); } }; return booleanTypeofTypeScript; })(); window.onload = function () { var access = new booleanTypeofTypeScript(); access.MyFunction(); };
مثال:
class NullTypeinTypeScript { MyFunction() { var p: number = null; var x = null; if (p== null) { alert("p has null value!"); } else { alert("p has a value"); } } } window.onload = () =>{ var value = new NullTypeinTypeScript(); value.MyFunction(); }
var NullTypeinTypeScript = (function () { function NullTypeinTypeScript() { } NullTypeinTypeScript.prototype.MyFunction = function () { var p = null; var x = null; if(p == null) { alert("p has null value!"); } else { alert("p has a value"); } }; return NullTypeinTypeScript; })(); window.onload = function () { var value = new NullTypeinTypeScript(); value.MyFunction(); };
undefined:معادل نوع undefined در Javascript است. اگر به یک متغیر مقدار اختصاص ندهید مقدار آن undefined خواهد بود.
مثال:
class UndefinedTypeOfTypeScript { Myfunction() { var p: number; var x = undefined; if (p == undefined && x == undefined) { alert("p and x is undefined"); } else { alert("p and c cannot undefined"); } } } window.onload = () =>{ var value = new UndefinedTypeOfTypeScript(); value.Myfunction(); }
var UndefinedTypeOfTypeScript = (function () { function UndefinedTypeOfTypeScript() { } UndefinedTypeOfTypeScript.prototype.Myfunction = function () { var p; var x = undefined; if(p == undefined && x == undefined) { alert("p and x is undefined"); } else { alert("p and c cannot undefined"); } }; return UndefinedTypeOfTypeScript; })(); window.onload = function () { var value = new UndefinedTypeOfTypeScript(); value.Myfunction(); };
ادامه دارد...
نظرات مطالب
اجرای یک Script حاوی دستورات Go در سی شارپ
سلام؛ سال نو مبارک :)
آقای کیاست، بهترین روش برای اجرای Script هایی که حاوی کلمه کلیدی GO هستند، استفاده از SMO است. به کد زیر دقت کنید:
اینجا همه چیز توسط SMO کنترل میشه و دیگه نیازی به آنالیز Script اصلی بر اساس عبارت GO نیست.
موفق باشید.
آقای کیاست، بهترین روش برای اجرای Script هایی که حاوی کلمه کلیدی GO هستند، استفاده از SMO است. به کد زیر دقت کنید:
Server server = new Server(new ServerConnection() { ConnectionString = cnnStr }); server.ConnectionContext.ExecuteNonQuery(sql);
موفق باشید.
نظرات مطالب
بازگردانی پایگاه داده بدون فایل لاگ
آقای نصیری ممنون با همون روش اول حل شد.
USE [master] GO -- Method 1: I use this method EXEC sp_attach_single_file_db @dbname='TestDb', @physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf' GO
اشتراکها
5.Visual Studio 2017 15.8 منتشر شد
These are the customer-reported issues addressed in 15.8.5:
- Debugger tooltip does not expand in Xamarin.iOS debugging session.
- Debugger won't let me leave execution point (Android).
- After updating to 15.8.1, data tip does not show when debugging.
- Debugger data tip does not expand [Editor].
- Exception:MSB0001: Internal MSBuild Error: Already registered for build-time.
- Wrong path to resource in manifest for ClickOnce after upgrading to VS 15.8.1.
- ClickOnce Manifest error in 15.8.
- ClickOnce Publish is missing certain references.
- ClickOnce: Language file copied to wrong location.
- Reference missing in the ClickOnce publish folder.
- Compiling non-.NET SDK style F# projects results in an internal MSBuild error unless MSBuild parallelism is set to 1.
- F# is not NGEN'd in Visual Studio.
- F# deploys the FSharp.Core 4.5.0.0 binary in the 4.4.3.0 location.
Details of What's New in 15.8.5
Visual Studio Tools for Xamarin
Visual Studio Tools for Xamarin now supports Xcode 10, which allows you to build and debug apps for iOS 12, tvOS 12, and watchOS 5. See how to get ready for iOS 12 and our introduction to iOS 12 for more details on the new features available.
اشتراکها
نگاهی به NET Standard 2.0.
مطالب
Image Annotations
میخواهیم با تغییر jQuery Image Annotation این پلاگین و برای asp.net استفاده کنیم
ایجاد دیتابیس
ابتدا یک دیتابیس به نام Coordinates ایجاد کنید و سپس جدول زیر رو ایجاد کنید
ایجاد کلاس Coords برای خواندن و ذخیره اطلاعات
فرم اصلی برنامه شامل 3 وب سرویس به شرح زیر میباشد
1-GetDynamicContext
این متد در زمان لود اطلاعات از دیتابیس استفاده میشود (وقتی که postback صورت میگیرد)
2,3 -SaveCoordsو DeleteCoords
این دو متد هم واسه ذخیره و حذف میباشند که نکته خاصی ندارند و خودتون بهینه اش کنید(در فایل ضمیمه موجودند)
تغییر فایل jquery.annotate.js جهت فراخوانی وب سرویس ها
فقط لازمه که سه قسمت زیر رو در فایل اصلی تغییر بدید
این پروژه شامل یه سری فایل css هم هست که میتونید کل پروژه رو از اینجا دانلود کنید
ایجاد دیتابیس
ابتدا یک دیتابیس به نام Coordinates ایجاد کنید و سپس جدول زیر رو ایجاد کنید
USE [Coordinates] GO CREATE TABLE [dbo].[Coords2]( [top] [int] NULL, [left] [int] NULL, [width] [int] NULL, [height] [int] NULL, [text] [nvarchar](50) NULL, [id] [uniqueidentifier] NULL, [editable] [bit] NULL ) ON [PRIMARY] GO
ایجاد کلاس Coords برای خواندن و ذخیره اطلاعات
public class Coords { public string top; public string left; public string width; public string height; public string text; public string id; public string editable; public Coords(string top, string left, string width, string height, string text, string id, string editable) { this.top = top; this.left = left; this.width = width; this.height = height; this.text = text; this.id = id; this.editable = editable; } }
1-GetDynamicContext
این متد در زمان لود اطلاعات از دیتابیس استفاده میشود (وقتی که postback صورت میگیرد)
[WebMethod] public static List<Coords> GetDynamicContext(string entryId, string entryName) { List<Coords> CoordsList = new List<Coords>(); string connect = "Connection String"; using (SqlConnection conn = new SqlConnection(connect)) { string query = "SELECT [top], [left], width, height, text, id, editable FROM Coords2"; using (SqlCommand cmd = new SqlCommand(query, conn)) { conn.Open(); using (SqlDataReader reader=cmd.ExecuteReader()) { while (reader.Read()) { CoordsList.Add(new Coords(reader["top"].ToString(), reader["left"].ToString(), reader["width"].ToString(), reader["height"].ToString(), reader["text"].ToString(), reader["id"].ToString(), reader["editable"].ToString())); } } conn.Close(); } } return CoordsList; }
2,3 -SaveCoordsو DeleteCoords
این دو متد هم واسه ذخیره و حذف میباشند که نکته خاصی ندارند و خودتون بهینه اش کنید(در فایل ضمیمه موجودند)
تغییر فایل jquery.annotate.js جهت فراخوانی وب سرویس ها
فقط لازمه که سه قسمت زیر رو در فایل اصلی تغییر بدید
$.fn.annotateImage.ajaxLoad = function (image) { ///<summary> ///Loads the annotations from the "getUrl" property passed in on the /// options object. ///</summary> $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Default.aspx/GetDynamicContext", data: "{'entryId': '" + 1 + "','entryName': '" + 2 + "'}", dataType: "json", success: function (msg) { image.notes = msg.d; $.fn.annotateImage.load(image); } });
};
$.fn.SaveCoords = function (note) { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Default.aspx/SaveCoords", data: "{'top': '" + note.top + "','left': '" + note.left + "','width': '" + note.width + "','height': '" + note.height + "','text': '" + note.text + "','id': '" + note.id + "','editable': '" + note.editable + "'}", dataType: "json", success: function (msg) { note.id = msg.d; } });
};
$.fn.annotateView.prototype.edit = function () {
///<summary>
///Edits the annotation.
///</summary>
if (this.image.mode == 'view') {
this.image.mode = 'edit';
var annotation = this;
// Create/prepare the editable note elements
var editable = new $.fn.annotateEdit(this.image, this.note);
$.fn.annotateImage.createSaveButton(editable, this.image, annotation);
// Add the delete button
var del = $('<a>حذف</a>');
del.click(function () {
var form = $('#image-annotate-edit-form form');
$.fn.annotateImage.appendPosition(form, editable)
if (annotation.image.useAjax) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/DeleteCoords",
// url: annotation.image.deleteUrl,
// data: form.serialize(),
data: "{'id': '" + editable.note.id + "'}",
dataType: "json",
success: function (msg) {
// image.notes = msg.d;
// $.fn.annotateImage.load(image);
},
error: function (e) { alert("An error occured deleting that note.") }
});
}
annotation.image.mode = 'view';
editable.destroy();
annotation.destroy();
});
editable.form.append(del);
$.fn.annotateImage.createCancelButton(editable, this.image);
}
};