استفاده از لایسنس Doconut
دستورالعملهای نصب و فعالسازی لایسنس شما.
برای یادگیری نحوه استفاده از لایسنس Doconut، دستورالعملهای زیر را برای پلتفرمهای مختلف .NET دنبال کنید.
نصب لایسنس Doconut
.NET Framework
تشخیص خودکار لایسنس
Doconut میتواند لایسنسها را بهصورت خودکار در پوشهٔ bin پروژه شناسایی کند.
افزودن لایسنس بهصورت دستی
اگر ترجیح میدهید لایسنس را بهصورت دستی اضافه کنید، گزینههای زیر در دسترس هستند:
افزودن لایسنس با مسیر فایل
این روش با استفاده از overload Viewer.DoconutLicense(string licencePath) لایسنس را از مسیر فایل مشخص شده بارگذاری میکند.
var licensePath = "path/to/your/license.lic";
Viewer.DoconutLicense(licensePath);افزودن لایسنس با Stream
این روش با استفاده از overload Viewer.DoconutLicense(Stream licenseStream) لایسنس را از یک Stream بارگذاری میکند.
using (var licenseStream = new FileStream("path/to/your/license", FileMode.Open))
{
Viewer.DoconutLicense(licenseStream);
}افزودن لایسنس با سند XML
این روش با استفاده از overload Viewer.DoconutLicense(XMLDocument licence) لایسنس را از یک سند XML بارگذاری میکند.
var xmlDoc = new XmlDocument();
xmlDoc.Load("path/to/your/license.xml");
Viewer.DoconutLicense(xmlDoc);افزودن لایسنس افزونه با مسیر فایل
این روش با استفاده از overload Viewer.SetLicensePlugin(string pathPluginLicence) لایسنس افزونه را از مسیر فایل مشخص شده بارگذاری میکند.
var pluginLicensePath = "path/to/your/plugin-license.lic";
Viewer.SetLicensePlugin(pluginLicensePath);افزودن لایسنس افزونه با Stream
این روش با استفاده از overload Viewer.SetLicensePlugin(Stream pluginLicence) لایسنس افزونه را از یک Stream بارگذاری میکند.
using (var pluginLicenseStream = new FileStream("path/to/your/plugin-license.lic", FileMode.Open))
{
Viewer.SetLicensePlugin(pluginLicenseStream);
}افزودن لایسنس افزونه با سند XML
این روش با استفاده از overload Viewer.SetLicensePlugin(XMLDocument xmlPluginLicence) لایسنس افزونه را از یک سند XML بارگذاری میکند.
var pluginXmlDoc = new XmlDocument();
pluginXmlDoc.Load("path/to/your/plugin-license.xml");
Viewer.SetLicensePlugin(pluginXmlDoc);.NET Standard/Core و .NET 6 و بالاتر
تشخیص خودکار لایسنس
Doconut میتواند لایسنسها را بهصورت خودکار در پوشهٔ wwwroot برنامه شناسایی کند.
برای مقداردهی اولیهٔ docViewer با تشخیص خودکار لایسنس، از خط زیر استفاده کنید:
var docViewer = new Viewer(_cache, _accessor);افزودن لایسنس بهصورت دستی
میتوانید مسیر یک فایل لایسنس پیشفرض را هنگام مقداردهی viewer بهصورت زیر مشخص کنید:
var licenseFilePath = Path.Combine(_hostingEnvironment.WebRootPath, "path/to/your/license");
var docViewer = new Viewer(_cache, _accessor, licenseFilePath);افزودن لایسنس با Stream
این روش با استفاده از overload Viewer.DoconutLicense(Stream licenseStream) لایسنس را از یک Stream بارگذاری میکند.
using (var licenseStream = new FileStream("path/to/your/license", FileMode.Open))
{
Viewer.DoconutLicense(licenseStream);
}افزودن لایسنس با سند XML
این روش با استفاده از overload Viewer.DoconutLicense(XMLDocument licence) لایسنس را از یک سند XML بارگذاری میکند.
var xmlDoc = new XmlDocument();
xmlDoc.Load("path/to/your/license.xml");
Viewer.DoconutLicense(xmlDoc);افزودن چند لایسنس افزونه بهصورت پیشفرض
اگر نیاز به ارائه چند لایسنس دارید، میتوانید لیستی از مسیرهای فایل را هنگام مقداردهی viewer ارائه کنید.
List<string> licenseFilePaths = new List<string>
{
Path.Combine(_hostingEnvironment.WebRootPath, "Doconut.Viewer.lic"),
Path.Combine(_hostingEnvironment.WebRootPath, "Doconut.Viewer.Annotation.lic"),
Path.Combine(_hostingEnvironment.WebRootPath, "Doconut.Viewer.Search.lic")
};
var docViewer = new Viewer(_cache, _accessor, licenseFilePaths);افزودن لایسنس افزونه با Stream
این روش با استفاده از overload Viewer.SetLicensePlugin(Stream pluginLicence) لایسنس افزونه را از یک Stream بارگذاری میکند.
using (var pluginLicenseStream = new FileStream("path/to/your/plugin-license.lic", FileMode.Open))
{
Viewer.SetLicensePlugin(pluginLicenseStream);
}افزودن لایسنس افزونه با سند XML
این روش با استفاده از overload Viewer.SetLicensePlugin(XMLDocument xmlPluginLicence) لایسنس افزونه را از یک سند XML بارگذاری میکند.
var pluginXmlDoc = new XmlDocument();
pluginXmlDoc.Load("path/to/your/plugin-license.xml");
Viewer.SetLicensePlugin(pluginXmlDoc);حفاظت از فایل لایسنس شما
برای محافظت از فایل لایسنس Doconut (.lic) ضروری است که آن را در یک مسیر امن و دسترسی محدود ذخیره کنید. اطمینان حاصل کنید که فقط برنامه یا سرویسهای مجاز بتوانند به این فایل دسترسی داشته باشند.