private static void RegisterCommands(int count, Type attrT, Assembly assembly, ref Dictionary <Type, int> defineTbl, out CreatorDelegate[] creatorList)
        {
            creatorList = new CreatorDelegate[count];
            Type[] types = assembly.GetTypes();
            int    idx   = 0;

            while (types != null && idx < types.Length)
            {
                Type     type        = types[idx++];
                object[] customAttrs = type.GetCustomAttributes(attrT, true);
                for (int i = 0; i < customAttrs.Length; i++)
                {
                    FrameClassAttribute attr = customAttrs[i] as FrameClassAttribute;
                    if (attr != null)
                    {
                        CreatorDelegate creator = GetCreator(type);
                        if (creator != null)
                        {
                            creatorList[attr.CreatorID] = creator;
                            defineTbl.Add(type, attr.CreatorID);

                            break;
                        }
                    }
                }
            }
        }
        public static object Create(Type type, EditorData data)
        {
            if (type.IsEditable() == false)
            {
                throw new ArgumentException("Type is not Editable!");
            }

            if (data is null)
            {
                throw new ArgumentNullException("Data is null!");
            }

            CreatorDelegate creatorDelegate = FindCreator(type);

            if (creatorDelegate is null)
            {
                throw new Exception("No Creator was found!");
            }

            try
            {
                return(creatorDelegate(data));
            }
            catch (Exception ex)
            {
                throw new Exception("Exception within the creator! (It will be thrown after this Exception.)", ex);
                throw;
            }
        }
Example #3
0
 public static IFrameCommand CreateFrameCommand(ref FRAME_CMD_PKG msg)
 {
     if ((msg.bCmdType >= 0) && (msg.bCmdType < s_CommandCreator.Length))
     {
         CreatorDelegate delegate2 = s_CommandCreator[msg.bCmdType];
         object[]        objArray1 = new object[] { msg.bCmdType };
         DebugHelper.Assert(delegate2 != null, "Creator is null at index {0}", objArray1);
         return(delegate2(ref msg));
     }
     object[] inParameters = new object[] { msg.bCmdType };
     DebugHelper.Assert(false, "not register framec ommand creator {0}", inParameters);
     return(null);
 }
Example #4
0
        public override void Init()
        {
            FrameCommandFactory.PrepareRegisterCommand();
            Assembly assembly = typeof(FrameSynchr).get_Assembly();

            Type[] types = assembly.GetTypes();
            int    num   = 0;

            while (types != null && num < types.Length)
            {
                Type     type             = types[num];
                object[] customAttributes = type.GetCustomAttributes(typeof(FrameCommandClassAttribute), true);
                for (int i = 0; i < customAttributes.Length; i++)
                {
                    FrameCommandClassAttribute frameCommandClassAttribute = customAttributes[i] as FrameCommandClassAttribute;
                    if (frameCommandClassAttribute != null)
                    {
                        CreatorDelegate creator = this.GetCreator(type);
                        if (creator != null)
                        {
                            FrameCommandFactory.RegisterCommandCreator(frameCommandClassAttribute.get_ID(), type, creator);
                        }
                    }
                }
                object[] customAttributes2 = type.GetCustomAttributes(typeof(FrameCSSYNCCommandClassAttribute), true);
                for (int j = 0; j < customAttributes2.Length; j++)
                {
                    FrameCSSYNCCommandClassAttribute frameCSSYNCCommandClassAttribute = customAttributes2[j] as FrameCSSYNCCommandClassAttribute;
                    if (frameCSSYNCCommandClassAttribute != null)
                    {
                        CreatorCSSyncDelegate cSSyncCreator = this.GetCSSyncCreator(type);
                        if (cSSyncCreator != null)
                        {
                            FrameCommandFactory.RegisterCSSyncCommandCreator(frameCSSYNCCommandClassAttribute.get_ID(), type, cSSyncCreator);
                        }
                    }
                }
                object[] customAttributes3 = type.GetCustomAttributes(typeof(FrameSCSYNCCommandClassAttribute), true);
                for (int k = 0; k < customAttributes3.Length; k++)
                {
                    FrameSCSYNCCommandClassAttribute frameSCSYNCCommandClassAttribute = customAttributes3[k] as FrameSCSYNCCommandClassAttribute;
                    if (frameSCSYNCCommandClassAttribute != null)
                    {
                        FrameCommandFactory.RegisterSCSyncCommandCreator(frameSCSYNCCommandClassAttribute.get_ID(), type, null);
                    }
                }
                num++;
            }
            this.ResetSynchr();
        }
 public static IFrameCommand CreateFrameCommand(ref FRAME_CMD_PKG msg)
 {
     if (msg.bCmdType >= 0 && (int)msg.bCmdType < FrameCommandFactory.s_CommandCreator.Length)
     {
         CreatorDelegate creatorDelegate = FrameCommandFactory.s_CommandCreator[(int)msg.bCmdType];
         DebugHelper.Assert(creatorDelegate != null, "Creator is null at index {0}", new object[]
         {
             msg.bCmdType
         });
         return(creatorDelegate(ref msg));
     }
     DebugHelper.Assert(false, "not register framec ommand creator {0}", new object[]
     {
         msg.bCmdType
     });
     return(null);
 }
Example #6
0
 public override void Init()
 {
     FrameCommandFactory.PrepareRegisterCommand();
     System.Type[] types = typeof(FrameSynchr).Assembly.GetTypes();
     for (int i = 0; (types != null) && (i < types.Length); i++)
     {
         System.Type inType           = types[i];
         object[]    customAttributes = inType.GetCustomAttributes(typeof(FrameCommandClassAttribute), true);
         for (int j = 0; j < customAttributes.Length; j++)
         {
             FrameCommandClassAttribute attribute = customAttributes[j] as FrameCommandClassAttribute;
             if (attribute != null)
             {
                 CreatorDelegate creator = this.GetCreator(inType);
                 if (creator != null)
                 {
                     FrameCommandFactory.RegisterCommandCreator(attribute.ID, inType, creator);
                 }
             }
         }
         object[] objArray2 = inType.GetCustomAttributes(typeof(FrameCSSYNCCommandClassAttribute), true);
         for (int k = 0; k < objArray2.Length; k++)
         {
             FrameCSSYNCCommandClassAttribute attribute2 = objArray2[k] as FrameCSSYNCCommandClassAttribute;
             if (attribute2 != null)
             {
                 CreatorCSSyncDelegate cSSyncCreator = this.GetCSSyncCreator(inType);
                 if (cSSyncCreator != null)
                 {
                     FrameCommandFactory.RegisterCSSyncCommandCreator(attribute2.ID, inType, cSSyncCreator);
                 }
             }
         }
     }
     this.ResetSynchr();
 }
 public static void RegisterCommandCreator(FRAMECMD_ID_DEF CmdID, Type CmdType, CreatorDelegate Creator)
 {
     FrameCommandFactory.s_CommandCreator[CmdID] = Creator;
     FrameCommandFactory.s_CommandTypeDef.Add(CmdType, CmdID);
 }
 public ProviderCreator(string name, CreatorDelegate creator)
 {
     this.name    = name;
     this.creator = creator;
 }
Example #9
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the <see cref="TeSelectableViewFactory"/> class.
			/// </summary>
			/// <param name="viewName">Name of the view.</param>
			/// <param name="viewType">Type of the view.</param>
			/// <param name="creatorMethod">The creator method.</param>
			/// --------------------------------------------------------------------------------
			public TeSelectableViewFactory(string viewName, TeViewType viewType,
				CreatorDelegate creatorMethod)
			{
				m_viewName = viewName;
				m_creatorMethod = creatorMethod;
				m_viewType = viewType;
			}
Example #10
0
 public ObjectPool(CreatorDelegate creator, CleanerDelegate cleaner)
 {
     this.creator = creator;
     this.cleaner = cleaner;
     freeList     = new BetterList <T>();
 }
Example #11
0
 public static void RegisterCommandCreator(FRAMECMD_ID_DEF CmdID, System.Type CmdType, CreatorDelegate Creator)
 {
     s_CommandCreator[(int)CmdID] = Creator;
     s_CommandTypeDef.Add(CmdType, CmdID);
 }
Example #12
0
 public PhotoDialogViewModel(CreatorDelegate creator, int offset, IEnumerable<PhotoItem> initialPhotos)
 {
     Photos = new ObservableCollection<PhotoItem>(initialPhotos);
     _currentPhotoIndex = offset;
 }
Example #13
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the <see cref="TeSelectableViewFactory"/> class.
			/// </summary>
			/// <param name="userView">The user view.</param>
			/// <param name="creatorMethod">The creator method.</param>
			/// <param name="viewType">Type of the view.</param>
			/// --------------------------------------------------------------------------------
			public TeSelectableViewFactory(UserView userView, TeViewType viewType,
				CreatorDelegate creatorMethod)
			{
				m_UserView = userView;
				m_CreatorMethod = creatorMethod;
				m_ViewType = viewType;
			}