public abstract class BaseEntity { #region Properties /// <summary> /// gets or sets Identifier of this Entity /// </summary> public virtual long Id { get; set; } /// <summary> /// gets or sets date that this entity was created /// </summary> public virtual DateTime CreatedOn { get; set; } /// <summary> /// gets or sets Date that this entity was updated /// </summary> public virtual DateTime ModifiedOn { get; set; } /// <summary> /// indicate this entity is Locked for Modify /// </summary> public virtual bool ModifyLocked { get; set; } /// <summary> /// gets or sets date that this entity repoted last time /// </summary> public virtual DateTime? ReportedOn { get; set; } /// <summary> /// gets or sets counter for Content's report /// </summary> public virtual int ReportsCount { get; set; } /// <summary> /// gets or sets TimeStamp for prevent concurrency Problems /// </summary> public virtual byte[] RowVersion { get; set; } #endregion #region NavigationProperties /// <summary> /// gets ro sets User that Modify this entity /// </summary> public virtual User ModifiedBy { get; set; } /// <summary> /// gets ro sets Id of User that modify this entity /// </summary> public virtual long? ModifiedById { get; set; } /// <summary> /// gets ro sets User that Create this entity /// </summary> public virtual User CreatedBy { get; set; } /// <summary> /// gets ro sets User that Create this entity /// </summary> public virtual long CreatedById { get; set; } #endregion }
- ReportedOn : نگهداری آخرین تاریخ اخطار
- ModifyLocked : به منظور ممانعت از ویرایش
- CreatedBy,CreatedById : به منظور ایجاد ارتباط یک به چند بین کاربر و سایر موجودیتها (به عنوان ایجاد کننده)
- ModifiedBy , ModifiedById : به منظور ایجاد ارتباط یک به چند بین کاربر و سایر موجودیتها (به عنوان آخرین تغییر دهنده)
مدل کلکسیون (کالکشن ،Collection)
/// <summary> /// Represents the Collection for group posts by topic /// </summary> public class Collection : GuidBaseEntity { #region Properties /// <summary> /// gets or sets name of collection /// </summary> public virtual string Name { get; set; } /// <summary> /// gets or sets Alternative SlugUrl /// </summary> public virtual string SlugUrl { get; set; } /// <summary> /// gets or sets some description of group /// </summary> public virtual string Description { get; set; } /// <summary> /// gets or sets description that indicate how to pay /// </summary> public virtual string HowToPay { get; set; } /// <summary> /// gets or sets Visibility Type /// </summary> public virtual CollectionVisibility Visibility { get; set; } /// <summary> /// gets or sets color of Collection's Cover /// </summary> public virtual string Color { get; set; } /// <summary> /// gets or sets Name of Image that used as Cover /// </summary> public virtual string Photo { get; set; } /// <summary> /// gets or sets name of tags seperated by comma that assosiated with this content fo increase performance /// </summary> public virtual string TagNames { get; set; } /// <summary> /// indicate this collection is active or not /// </summary> public virtual bool IsActive { get; set; } #endregion #region NavigationProperties /// <summary> /// get or set collection of attachments that attached in this group /// </summary> public virtual ICollection<CollectionAttachment> Attachments { get; set; } /// <summary> /// get or set tags of collection /// </summary> public virtual ICollection<Tag> Tags { get; set; } /// <summary> /// get or set List Of Posts that Associated with this Collection /// </summary> public virtual ICollection<CollectionPost> Posts { get; set; } /// <summary> /// get or set Users that they are Member of this collection if visibility is Custom /// </summary> public virtual ICollection<User> Memebers { get; set; } #endregion } public enum CollectionVisibility { Friends, OnlyMe, Public, NotFree, Custom }
- Visibility : برای اعمال محدودیت دسترسی به یک کلکسیون در نظر گرفته شده است. از نوع، نوع دادهی شمارشی CollectionVisibility پیاده سازی شدهی دربالا، میباشد. حالت Custom برای زمانی است که نیاز است صرفا یک سری از کاربران بدون هزینه، دسترسی برای مطالعهی این کلکسیون داشته باشند. حالت NotFree هم برای زمانی است که کاربرانی که هزینهی مورد نظر را پرداخت کرده باشند، به عنوان عضو به این کلکسیون میتوانند دسترسی داشته باشند.
- Members : به منظور اعمال ارتباط چند به چند بین مدل کاربر و مدل کلکسیون، در نظر گرفته شده است و زمانی این لیست اعضا خالی نیست که حالت Visibility با NotFree یا Custom مقدار دهی شده باشد.
- Tags : برای یافتن راحتتر کلکسیونهای مورد نظر کاربران، یک ارتباط چند به چند بین کلکسیونها و مخزن برچسب مطرح شدهی در مقاله اول، در نظر گرفته شده است.
- TagNames : برای افزایش کارآیی سیستم در نظر گرفته شده است و نام برچسبهای در ارتباط با کلکسیون را در خود به صورت جدا شده با (,) نگهداری میکند.
- Posts : لیست پستهایی است که توسط مدیر کلکسیون در آن ارسال میشود. لذا یک ارتباط یک به چند بین کلکسیونها و CollectionPost در نظر گرفته شده است.
- Attachments : لیست فایلهایی است که در کلکسیون بارگذاری شدهاند (در ادامه پیاده سازی خواهد شد).
- Owner , OwnerId : هر کلکسیون نیز یک صاحب خواهد داشت. بدین منظور یک ارتباط یک به چند بین کاربر و کلکسیون برقرار شده است.
- HowToPay : توضیحاتی در مورد نحوهی پرداخت هزینه (در صورتی که Visibility این کلکسیون NotFree باشد).
مدل پستهای کلکسیون ها
public class CollectionPost : GuidBaseEntity { #region Properties /// <summary> /// indicate this post should be pin /// </summary> public virtual bool IsPin { get; set; } /// <summary> /// gets or sets the blog pot body /// </summary> public virtual string Body { get; set; } /// <summary> /// gets or sets the content title /// </summary> public virtual string Title { get; set; } /// <summary> /// gets or sets value indicating Custom Slug /// </summary> public virtual string SlugAltUrl { get; set; } /// <summary> /// gets or sets a value indicating whether the content comments are allowed /// </summary> public virtual bool AllowComments { get; set; } /// <summary> /// indicate comments should be approved before display /// </summary> public virtual bool ModerateComments { get; set; } /// <summary> /// gets or sets viewed count /// </summary> public virtual long ViewCount { get; set; } /// <summary> /// Gets or sets the total number of approved comments /// <remarks>The same as if we run Item.Comments.Count() /// We use this property for performance optimization (no SQL command executed) /// </remarks> /// </summary> public virtual int ApprovedCommentsCount { get; set; } /// <summary> /// Gets or sets the total number of unapproved comments /// <remarks>The same as if we run Item.Comments.Count() /// We use this property for performance optimization (no SQL command executed) /// </remarks> /// </summary> public virtual int UnApprovedCommentsCount { get; set; } /// <summary> /// gets or sets rating complex instance /// </summary> public virtual Rating Rating { get; set; } /// <summary> /// gets or sets information of User-Agent /// </summary> public virtual string Agent { get; set; } /// <summary> /// indicate users can share this post /// </summary> public virtual bool IsEnableForShare { get; set; } #endregion #region NavigationProperties /// <summary> /// get or set comments of this post /// </summary> public virtual ICollection<CollectionComment> Comments { get; set; } /// <summary> /// gets or sets collection that associated with this post /// </summary> public virtual Collection Collection { get; set; } /// <summary> /// gets or sets id of collection that associated with this post /// </summary> public virtual Guid CollectionId { get; set; } #endregion }
- IsEnableForShare : اگر با مقدار True مقدار دهی شده باشد ، امکان به اشتراک گذاری آن درشبکههای اجتماعی وجود خواهد داشت.
- Comments : اگر مقدار AllowComments مربوط به پست ارسالی true باشد، در آن صورت امکان نظر دهی به پست هم امکان پذیر خواهد بود. برای برقراری ارتباط یک به چند بین مدل پست کلکسیون و نظرات کلکسیون، این لیست در مدل بالا گنجانده شده است.
- ModerateComments : اگر برای پست خاصی، با مقدار true مقدار دهی شده باشد، نظرات آن پست قبل از نمایش باید توسط مدیر آن کلکسیون تأیید شوند.
- Author , AuthorId : در واقع ارسال کنندهی تمام پستها، همان صاحب کلکسیون میباشد. ولی برای راحتی واکشی لیست پستهای ارسالی کاربر مورد نظر یک ارتباط یک به چند بین کاربر و پستهای ارسالی را در کلکسیون اعمال کردهایم.
- Collection , CollectionId : کلید خارجی ما در دیتابیس ایجاد شده خواهد بود که نشان دهندهی ارتباط یک به چند بین کلکسیون و پستها میباشد.
- IsPin : اگر لازم است پستی به عنوان اولین پست در کلکسیون نمایش داده شود، این خصوصیت برای آن true خواهد بود.
- ApprovedCommentsCount , UnApprovedCommentsCount: برای افزایش کارآیی سیستم در نظر گرفته شده است و هنگام درج نظر جدید یا حذف نظر، ویرایش خواهند شد.
مدل نظرات ارسالی در کلکسیون ها
public class CollectionComment { #region Ctor public CollectionComment() { Id = SequentialGuidGenerator.NewSequentialGuid(); CreatedOn = DateTime.Now; } #endregion #region Properties /// <summary> /// get or set identifier of record /// </summary> public virtual Guid Id { get; set; } /// <summary> /// gets or sets date of creation /// </summary> public virtual DateTime CreatedOn { get; set; } /// <summary> /// gets or sets body of blog post's comment /// </summary> public virtual string Body { get; set; } /// <summary> /// gets or sets body of blog post's comment /// </summary> public virtual Rating Rating { get; set; } /// <summary> /// gets or sets informations of agent /// </summary> public virtual string UserAgent { get; set; } /// <summary> /// indicate this comment is Approved /// </summary> public virtual bool IsApproved { get; set; } /// <summary> /// gets or sets Ip Address of Creator /// </summary> public virtual string CreatorIp { get; set; } /// <summary> /// gets or sets datetime that is modified /// </summary> public virtual DateTime? ModifiedOn { get; set; } /// <summary> /// gets or sets counter for report this comment /// </summary> public virtual int ReportsCount { get; set; } /// <summary> /// indicate this entity is Locked for Modify /// </summary> public virtual bool ModifyLocked { get; set; } /// <summary> /// gets or sets date that this entity repoted last time /// </summary> public virtual DateTime? ReportedOn { get; set; } #endregion #region NavigationProperties /// <summary> /// gets or sets post that this comment added it /// </summary> public virtual CollectionPost Post { get; set; } /// <summary> /// gets or sets id of post that this comment added it /// </summary> public virtual Guid PostId { get; set; } /// <summary> /// get or set user that create this record /// </summary> public virtual User Creator { get; set; } /// <summary> /// get or set Id of user that create this record /// </summary> public virtual long CreatorId { get; set; } /// <summary> /// gets or sets CollectionComment's identifier for Replying and impelemention self referencing /// </summary> public virtual Guid? ReplyId { get; set; } /// <summary> /// gets or sets Collection's comment for Replying and impelemention self referencing /// </summary> public virtual CollectionComment Reply { get; set; } /// <summary> /// get or set collection of Collection's comment for Replying and impelemention self referencing /// </summary> public virtual ICollection<CollectionComment> Children { get; set; } #endregion }
مدل بالا نشان دهندهی نظرات ارسالی برای پستهای کلکسیونها میباشد. صرفا کاربران عضو سیستم این اجازه را در صورتی خواهند داشت که برای پست مورد نظر خصوصیت AllowComments با مقدار true مقدار دهی شده باشد
حالت درختی آن مشخص است. برای اعمال ارتباط یک به چند بین پستها و نظرات، از CollectionPost و CollectionPostId استفاده خواهد شد.
- IsApproved : برای زمانی استفاده خواهد شد که خصوصیت ModerateComments پست مورد نظر با مقدار true مقدار دهی شده باشد.
- ReportsCount : به مانند بخشهای قبل، تعداد اخطارهای داده شدهی برای یک نظر را نشان خواهد داد.
- Creator,CreatorId : ارسال کنندهی نظر میباشد و برای ایجاد ارتباط یک به چند بین کاربر و نظرات کلکسیونها در نظر گرفته شدهاند.
- ReportedOn : نگه داری آخرین تاریخ اخطار
- ModifyLocked : به منظور ممانعت از ویرایش
مدل فایلهای ضمیمه کلکسیون ها
public class CollectionAttachment : BaseAttachment { #region NavigationProperties /// <summary> /// gets or sets Collection that this file attached /// </summary> public virtual Collection Collection { get; set; } /// <summary> /// gets or sets Id of Collection that this file attached /// </summary> public virtual Guid? CollectionId { get; set; } #endregion }
مدل آگهی ها
/// <summary> /// Represents Announcement For Announcement Section /// </summary> public class Announcement : BaseContent { #region Properties /// <summary> /// gets or sets Date that this Announcement will Expire /// </summary> public virtual DateTime? ExpireOn { get; set; } /// <summary> /// indicate this accouncement is approved by admin if announcementSetting.Moderate==true /// </summary> public virtual bool IsApproved { get; set; } #endregion #region NavigationProperties /// <summary> /// get or set Collection of Comments for this Announcement /// </summary> public virtual ICollection<AnnouncementComment> Comments { get; set; } #endregion }
- ExpireOn : زمان انقضای آگهی
- IsApproved : به منظور اعمال مدیریتی در نظر گرفته شده است
- Comments : اگر امکان ارسال نظرات برای آگهی از بخش تنظیمات فعال باشد، این لیست نظرات ما را نگه داری خواهد کرد. لذا یک رابطهی یک به چند بین نظرات و آگهیها خواهد بود.
مدل نظرات آگهی ها
/// <summary> /// Repersents Comment For Announcement /// </summary> public class AnnouncementComment : BaseComment { #region NavigationProperties /// <summary> /// gets or sets body of announcement's comment /// </summary> public virtual long? ReplyId { get; set; } /// <summary> /// gets or sets body of announcement's comment /// </summary> public virtual AnnouncementComment Reply { get; set; } /// <summary> /// gets or sets body of announcement's comment /// </summary> public virtual ICollection<AnnouncementComment> Children { get; set; } /// <summary> /// gets or sets announcement that this comment sent to it /// </summary> public virtual Announcement Announcement { get; set; } /// <summary> /// gets or sets announcement'Id that this comment sent to it /// </summary> public virtual long AnnouncementId { get; set; } #endregion }
مدل سیستم لاگ عملیات کاربران
/// <summary> /// Represent The Operation's log /// </summary> public class AuditLog { #region Ctor /// <summary> /// /// </summary> public AuditLog() { Id = SequentialGuidGenerator.NewSequentialGuid(); OperatedOn = DateTime.Now; } #endregion #region Properties /// <summary> /// sets or gets identifier of AuditLog /// </summary> public virtual Guid Id { get; set; } /// <summary> /// sets or gets description of Log /// </summary> public virtual string Description { get; set; } /// <summary> /// sets or gets when log is operated /// </summary> public virtual DateTime OperatedOn { get; set; } /// <summary> /// sets or gets log's section /// </summary> public virtual AuditSection Section { get; set; } #endregion #region NavigationProperties /// <summary> /// sets or gets log's creator /// </summary> public virtual User OperatedBy { get; set; } /// <summary> /// sets or gets identifier of log's creator /// </summary> public virtual long OperatedById { get; set; } #endregion } public enum AuditSection { Blog, News, Forum, ... }
مدل دامینهای ممنوع
/// <summary> /// Represents Domain that is banned /// </summary> public class BannedDomain { #region Propertie /// <summary> /// gets or sets identifier of Domain /// </summary> public virtual Guid Id { get; set; } /// <summary> /// gets or sets DomainName /// </summary> public virtual string Name { get; set; } /// <summary> /// gets or sets Date that this record added /// </summary> public virtual DateTime BannedOn { get; set; } #endregion }
مدل کلمات ممنوع
/// <summary> /// Represents the banned words /// </summary> public class BannedWord { #region Ctor /// <summary> /// Create one instance of <see cref="BannedWord"/> /// </summary> public BannedWord() { Id = SequentialGuidGenerator.NewSequentialGuid(); } #endregion #region Properties /// <summary> /// gets or sets identifier of BannedWord /// </summary> public Guid Id { get; set; } /// <summary> /// gets or sets Bad word /// </summary> public string BadWord { get; set; } /// <summary> /// gets or sets Good replaceword /// </summary> public string GoodWord { get; set; } /// <summary> /// indicating that this Word is spam /// </summary> public bool IsStopWord { get; set; } #endregion }
- BadWord : کلمه مورد نظر که قرار است Ban شود.
- IsStopWord : اگر لازم نیست جایگزینی برای کلمه استفاده شود و فقط لازم است حذف گردد، مقدار این خصوصیت true خواهد بود.
- GoodWord : کلمه جایگزین
مدل تنظیمات سیستم
/// <summary> /// Represent The CMS setting /// </summary> public class Setting { #region Properties /// <summary> /// sets or gets name of setting /// </summary> public virtual string Name { get; set; } /// <summary> /// sets or gets value of setting /// </summary> public virtual string Value { get; set; } /// <summary> /// sets or gets Type of setting /// </summary> public virtual string Type { get; set; } #endregion }
نتیجهی این قسمت
دوره #C برای تازهکارها
C# Tutorial For Beginners Full Course | Csharp tutorial for beginners
In this course you will learn how to start in your computer programming path using one of the most relevant programming languages: C#. You will get a good understanding on the basics of how Visual Studio 2019 compiles console-based programs. Finally, this class will pave the way to expanding intermediate C# concepts by creating a good foundation for you in very important concepts such as C# data types, decision making, looping and C# methods.
function testScope() { var myTest = true; if (true) { var myTest = "I am changed!" } alert(myTest); } testScope(); // will alert "I am changed!"
function testScope() { var myTest = true; if (true) { var myTest = "I am changed!" } alert(myTest); } testScope(); // will alert "I am changed!" alert(myTest); // will throw a reference error, because it doesn't exist outside of the function
<script type="text/javascript"> // a globally-scoped variable var a = 1; // global scope function one() { alert(a); } // local scope function two(a) { alert(a); } // local scope again function three() { var a = 3; alert(a); } // Intermediate: no such thing as block scope in javascript function four() { if (true) { var a = 4; } alert(a); // alerts '4', not the global value of '1' } // Intermediate: object properties function Five() { this.a = 5; } // Advanced: closure var six = function () { var foo = 6; return function () { // javascript "closure" means I have access to foo in here, // because it is defined in the function in which I was defined. alert(foo); } }() // Advanced: prototype-based scope resolution function Seven() { this.a = 7; } // [object].prototype.property loses to [object].property in the lookup chain Seven.prototype.a = -1; // won't get reached, because 'a' is set in the constructor above. Seven.prototype.b = 8; // Will get reached, even though 'b' is NOT set in the constructor. // These will print 1-8 one(); two(2); three(); four(); alert(new Five().a); six(); alert(new Seven().a); alert(new Seven().b); </Script>
var obj = { value: 0, increment: function() { this.value+=1; } }; obj.increment(); //Method invocation
<script type="text/javascript"> var value = 500; //Global variable var obj = { value: 0, increment: function() { this.value++; var innerFunction = function() { alert(this.value); } innerFunction(); //Function invocation pattern } } obj.increment(); //Method invocation pattern <script type="text/javascript"> Result : 500
<script type="text/javascript"> var value = 500; //Global variable var obj = { value: 0, increment: function() { var that = this; that.value++; var innerFunction = function() { alert(that.value); } innerFunction(); //Function invocation pattern } } obj.increment(); <script type="text/javascript"> Result : 1
var Dog = function(name) { //this == brand new object ({}); this.name = name; this.age = (Math.random() * 5) + 1; }; var myDog = new Dog('Spike'); //myDog.name == 'Spike' //myDog.age == 2 var yourDog = new Dog('Spot'); //yourDog.name == 'Spot' //yourDog.age == 4
var createCallBack = function(init) { //First function return new function() { //Second function by Constructor Invocation var that = this; this.message = init; return function() { //Third function alert(that.message); } } } window.addEventListener('load', createCallBack("First Message")); window.addEventListener('load', createCallBack("Second Message"));
myFunction.apply(thisContext, arrArgs); myFunction.call(thisContext, arg1, arg2, arg3, ..., argN);
var contextObject = { testContext: 10 } var otherContextObject = { testContext: "Hello World!" } var testContext = 15; // Global variable function testFunction() { alert(this.testContext); } testFunction(); // This will alert 15 testFunction.call(contextObject); // Will alert 10 testFunction.apply(otherContextObject); // Will alert "Hello World”
var o = { i : 0, F : function() { var a = function() { this.i = 42; }; a(); document.write(this.i); } }; o.F(); Result :0
var p = { i : 0, F : function() { var a = function() { this.i = 42; }; a.apply(this); document.write(this.i); } }; p.F(); Result :42
var q = { i: 0, F: function F() { var that = this; var a = function () { that.i = 42; } a(); document.write(this.i); } } q.F();
How does a developer find a new tool to add to their stack? There’s no single answer, but most will tell you that technical content is part of that journey. Certainly, documentation is crucial to developer experience. But more often than not, the first piece of content they’ll discover is a helpful resource returned as search results or shared from another dev. Your goal is simple: be that resource.
انتشار مسیر راه Angular
Operation Bye Bye Backlog (aka Operation Byelog)
We are actively investing up to 50% of our engineering capacity on triaging issues and PRs until we have a clear understanding of broader community needs. After that, we'll commit up to 20% of our engineering capacity to keep up with new submissions promptly.کتابخانه WebApiThrottle
ASP.NET Web API Throttling handler, OWIN middleware and filter are designed to control the rate of requests that clients can make to a Web API based on IP address, client API key and request route.
public static void Register( HttpConfiguration config ) { config.MessageHandlers.Add( new ThrottlingHandler { Policy = new ThrottlePolicy( perSecond: 1, perMinute: 20, perHour: 200, perDay: 1500, perWeek: 3000 ) { IpThrottling = true }, Repository = new CacheRepository() } ); }