AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 30.07.2018, 20:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
d365technext: Private, Protected and Public attribute access in Class Extension
Источник: http://d365technext.blogspot.com/201...attribute.html
==============


Private, Protected and Public attribute access in Class Extension


lots of developer faced the issue on daily basis during development to access private, protected and public method.

As everyone know that public attribute is available to access with class instance.
but protected and private attribute are little difficult to access.

In this demo we show how to access all 3 access modifier using class extension.


Step-1 Create a class SLD_DemoClass.
Step-2 Declare 3 variable like below and one public method to set value in these variable.





Step-3 Now create Extension of this class with SLD_DemoClass_Extension.
Step-4 Create getter setter to access the variable.




for public and protected method its easy to access just to write simple getter setter method and can access these public methods using class instance.


Step-5 To Access private attribute in class extension, We need to use C# reflection library.

Step-6 Now write the below code to access private attribute on run-time.




following is the screenshot of the complete code of extension class.




Step-7 Now create a run-able class and action menu item to execute this code.




Step-8 perform build & Sync and login on D365FO for verification.



You can check in the screenshot all 3 protected, private and public attributes values in info message.


Please fee free to contact me if you are facing any issue during implementation of this blog.






Источник: http://d365technext.blogspot.com/201...attribute.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
sertandev: Using .NET attributes for D365 FO child class constructors Blog bot DAX Blogs 0 04.04.2018 14:11
sertandev: AX7 Extensibility Overview – Part 2 : Code extensions Blog bot DAX Blogs 0 28.08.2017 19:11
i-neti: X++ in AX7: элементы с уровнями доступа private и public. Часть 4 Blog bot DAX Blogs 0 18.04.2017 13:11
mfp: X++ in AX7: Private and public members Blog bot DAX Blogs 12 10.12.2015 09:08
ax_gfm_framework_team: The Microsoft Dynamics AX 2012 extension framework – Part 1 Blog bot DAX Blogs 0 14.11.2012 01:12

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 02:13.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.