Advertisement
Guest User

DocsVisionDictionaryExample

a guest
Apr 6th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4.  
  5. using DocsVision.Platform.CardHost;
  6. using DocsVision.Platform.ObjectModel;
  7. using DocsVision.Platform.ObjectModel.Mapping;
  8. using DocsVision.Platform.WinForms;
  9.  
  10. using DocsVision.BackOffice.ObjectModel;
  11. using DocsVision.BackOffice.ObjectModel.Mapping;
  12.  
  13. using DocsVision.BackOffice.WinForms;
  14.  
  15. using YourCompanyName.YourProjectName.ObjectModel;
  16. using YourCompanyName.YourProjectName.ObjectModel.Mapping;
  17.  
  18. namespace YourCompanyName.YourProjectName.ObjectModel
  19. {
  20.     public static class YourProject
  21.     {
  22.         public static void Register(ObjectContext context)
  23.         {
  24.             context.GetService<IObjectMapperFactoryRegistry>().RegisterFactory(typeof(YourProjectNameMapperFactory));
  25.         }
  26.     }
  27.  
  28.     public class YourDictionaryCard : BaseCard
  29.     {
  30.         #region Properties
  31.  
  32.         public override BaseCardSystemInfo SystemInfo
  33.         {
  34.             get { return null; }
  35.         }
  36.  
  37.         public override ObjectCollection<BaseCardProcess> Processes
  38.         {
  39.             get { return null; }
  40.         }
  41.  
  42.         /* some other sections of your dictionary */
  43.         #endregion
  44.  
  45.         #region Constructors
  46.  
  47.         protected internal YourDictionaryCard() : this(null) { }
  48.  
  49.         protected internal YourDictionaryCard(ObjectInitializationData data) : base(data) { }
  50.         #endregion
  51.     }
  52. }
  53.  
  54. namespace YourCompanyName.YourProjectName.ObjectModel.Mapping
  55. {
  56.     public sealed class YourProjectNameMapperFactory : ObjectMapperFactory
  57.     {
  58.         #region Constructors
  59.  
  60.         protected internal YourProjectNameMapperFactory(ObjectContext context) : base(context)
  61.         {
  62.             RegisterObjectMapper(typeof(YourDictionaryCard), typeof(YourDictionaryCardMapper));
  63.         }
  64.         #endregion
  65.     }
  66.  
  67.     public sealed class YourDictionaryCardMapper : BaseCardMapper<YourDictionaryCard>
  68.     {
  69.         #region Constructors
  70.  
  71.         protected internal YourDictionaryCardMapper(ObjectContext context) : base(context) { }
  72.         #endregion
  73.  
  74.         #region BaseCardMapper methods overriding
  75.  
  76.         protected override ObjectMap GetObjectMap()
  77.         {
  78.             return new ObjectMap(); // <<< build your dictionary card map here!
  79.         }
  80.  
  81.         protected override YourDictionaryCard CreateObject(ObjectInitializationData data)
  82.         {
  83.             return new YourDictionaryCard(data);
  84.         }
  85.         #endregion
  86.     }
  87. }
  88.  
  89. namespace YourCompanyName.YourProjectName.WinForms
  90. {
  91.     [Customizable(false), CardFrameWindowType(typeof(CardFrameForm))]
  92.     [ClassInterface(ClassInterfaceType.None), ComVisible(true), Guid("4226D147-C67B-4F3E-B690-E28C8379AB75")]
  93.     public partial class YourDictionaryCardControl : BaseCardControl
  94.     {
  95.         #region Properties
  96.  
  97.         public override BaseCard BaseObject
  98.         {
  99.             get { return DictionaryCard; }
  100.         }
  101.  
  102.         private YourDictionaryCard DictionaryCard
  103.         {
  104.             get
  105.             {
  106.                 return ObjectContext.GetObject<YourDictionaryCard>(CardData.Id);
  107.             }
  108.         }
  109.         #endregion
  110.  
  111.         #region Constructors
  112.  
  113.         public YourDictionaryCardControl() : base()
  114.         {
  115.             if (IsInDesignMode())
  116.             {
  117.                 InitializeComponent();
  118.             }
  119.         }
  120.         #endregion
  121.  
  122.         #region BaseCardControl methods overriding
  123.  
  124.         protected override void OnCardInitialized(EventArgs args)
  125.         {
  126.             base.OnCardInitialized(args);
  127.  
  128.             InitializeComponent();
  129.         }
  130.  
  131.         protected override void OnObjectContextInitializing(ObjectContextEventArgs args)
  132.         {
  133.             base.OnObjectContextInitializing(args);
  134.  
  135.             YourProject.Register(args.ObjectContext); // <<< register object mappers in object context
  136.         }
  137.         #endregion
  138.  
  139.         #region Class methods
  140.  
  141.         private void InitializeComponent() { }
  142.         #endregion
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement