Exemple #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <ActionInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(ActionInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <ActionInfo>);
            }
            else
            {
                List <ActionInfo> list       = new List <ActionInfo>();
                ActionCollection  collection = new  ActionCollection();
                Query             qry        = new Query(Action.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Action action in collection)
                {
                    ActionInfo actionInfo = new ActionInfo();
                    LoadFromDAL(actionInfo, action);
                    list.Add(actionInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(ActionInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
        public ActionCollection GetOutboundActions()
        {
            ActionCollection ac = new ActionCollection();

            ac.Add(new Action("Search", new string[0]));
            return(ac);
        }
Exemple #3
0
        private static Action FindAction(Guid actionId, string absoluteNavigateUrl, ActionCollection actions)
        {
            Action originalItem = null;

            if (actionId != Guid.Empty)
            {
                originalItem = actions.FindByActionId(actionId);
            }
            else if (!string.IsNullOrEmpty(absoluteNavigateUrl))
            {
                if (absoluteNavigateUrl.Contains("?"))
                {
                    originalItem = actions.FindByNavigateUrlPathAndQuery(absoluteNavigateUrl, true, true);
                    if (originalItem == null)
                    {
                        originalItem = actions.FindByNavigateUrlPathAndQuery(absoluteNavigateUrl, true, false);
                    }
                }
                if (originalItem == null)
                {
                    originalItem = actions.FindByNavigateUrl(absoluteNavigateUrl.Split('?')[0], true);
                }
            }

            return(originalItem);
        }
Exemple #4
0
        public static bool HasReplaceCollision(GameModification currentMod, string file, string replacementFile, List <FileModification> modifications, out ModCollision collision)
        {
            var actions = new ActionCollection(file, currentMod.Config.ModID, modifications);

            if (actions.moveAction != null)
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Replace, FileModificationType.Moved, actions.moveAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            if (actions.replaceAction != null && MD5Utility.CalculateMD5Hash(file) != MD5Utility.CalculateMD5Hash(replacementFile))
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Replace, FileModificationType.Replaced, actions.replaceAction.ModID, ModCollisionSeverity.Clash, out collision, suffix: "(with different data)"));
            }

            if (actions.editAction != null)
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Replace, FileModificationType.Edited, actions.editAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            if (actions.deleteAction != null)
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Replace, FileModificationType.Deleted, actions.deleteAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            collision = null;
            return(false);
        }
 public static void EnsureDataBindingOnActionsUpToDate(ActionCollection actions)
 {
     foreach (var action in actions)
     {
         EnsureDataBindingUpToDateOnMembers(action);
     }
 }
 public ContentTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEntityService entityService,
     IBackOfficeSecurityAccessor backofficeSecurityAccessor,
     ILogger <ContentTreeController> logger,
     ActionCollection actionCollection,
     IUserService userService,
     IDataTypeService dataTypeService,
     UmbracoTreeSearcher treeSearcher,
     ActionCollection actions,
     IContentService contentService,
     IPublicAccessService publicAccessService,
     ILocalizationService localizationService,
     IEventAggregator eventAggregator,
     IEmailSender emailSender,
     AppCaches appCaches)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService, eventAggregator, appCaches)
 {
     _treeSearcher = treeSearcher;
     _actions      = actions;
     _menuItemCollectionFactory  = menuItemCollectionFactory;
     _backofficeSecurityAccessor = backofficeSecurityAccessor;
     _contentService             = contentService;
     _entityService       = entityService;
     _publicAccessService = publicAccessService;
     _userService         = userService;
     _localizationService = localizationService;
     _emailSender         = emailSender;
     _appCaches           = appCaches;
 }
Exemple #7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if ((treeView1.SelectedNode.Tag as string) == "Root")
            {
                return;
            }
            if (!actions.Actions.ContainsKey(treeView1.SelectedNode.Text))
            {
                return;
            }
            ActionCollection bin = actions.Actions[treeView1.SelectedNode.Text];

            NewActionDialog dialog = new NewActionDialog();

            if (dialog.ShowDialog(treeView1.SelectedNode.Text, actions.Variables) == DialogResult.OK)
            {
                bin.Add(dialog.SelectedAction);
                treeView1.SelectedNode.Nodes.Add(new TreeNode()
                {
                    Text = dialog.SelectedAction.ClassName,
                    Name = dialog.SelectedAction.ClassName,
                    Tag  = dialog.SelectedAction,
                });
                treeView1.SelectedNode.Expand();
            }
        }
        public void VisgroupCreateNew()
        {
            using (var qf = new QuickForm("Create New Visgroup")
            {
                UseShortcutKeys = true
            }.TextBox("Name").CheckBox("Add selection to visgroup", true).OkCancel()) {
                if (qf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var ids = _document.Map.Visgroups.Where(x => !x.IsAutomatic).Select(x => x.ID).ToList();
                var id  = Math.Max(1, ids.Any() ? ids.Max() + 1 : 1);

                var name = qf.String("Name");
                if (String.IsNullOrWhiteSpace(name))
                {
                    name = "Visgroup " + id.ToString();
                }

                var vg = new Visgroup {
                    ID      = id,
                    Colour  = Colour.GetRandomLightColour(),
                    Name    = name,
                    Visible = true
                };
                IAction action = new CreateEditDeleteVisgroups(new[] { vg }, new Visgroup[0], new Visgroup[0]);
                if (qf.Bool("Add selection to visgroup") && !_document.Selection.IsEmpty())
                {
                    action = new ActionCollection(action, new EditObjectVisgroups(_document.Selection.GetSelectedObjects(), new[] { id }, new int[0]));
                }
                _document.PerformAction("Create visgroup", action);
            }
        }
        public void AddActionWithInvalidTypeTest()
        {
            var collection = new ActionCollection <string>();

            Assert.Throws <InvalidOperationException>(() => collection.AddAction(typeof(string)));
            Assert.Throws <InvalidOperationException>(() => collection.AddAction(typeof(IAction <string>)));
        }
Exemple #10
0
        public ActionCollection GetOutboundActions()
        {
            ActionCollection _outboundActions = new ActionCollection();

            _outboundActions.Add(new Action(BACK, new string[0]));
            return(_outboundActions);
        }
Exemple #11
0
        public static bool HasEditCollision(GameModification currentMod, string file, IWriteContent content, FileWriterUtility fileWriter, List <FileModification> modifications, out ModCollision collision)
        {
            var actions = new ActionCollection(file, currentMod.Config.ModID, modifications);

            if (actions.moveAction != null)
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Edit, FileModificationType.Moved, actions.moveAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            if (actions.replaceAction != null)
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Edit, FileModificationType.Replaced, actions.replaceAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            if (actions.editAction != null && !fileWriter.CanWrite(file, content))
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Edit, FileModificationType.Edited, actions.editAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            if (actions.deleteAction != null)
            {
                return(AddModCollision(currentMod, ModInstallActionEnum.Edit, FileModificationType.Deleted, actions.deleteAction.ModID, ModCollisionSeverity.Clash, out collision));
            }

            collision = null;
            return(false);
        }
Exemple #12
0
        public ActionCollection GetInboundActions()
        {
            ActionCollection inboundActions = new ActionCollection();

            inboundActions.Add(new Action("TourDetail", new string[0]));
            return(inboundActions);
        }
        public void Test_Action_Collection_Constructor_Int()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var sut = new ActionCollection(20);

            Assert.True(sut.Count == 0);
        }
        public bool IsCompatibleWithBot(ActionCollection botActions)
        {
            foreach (MyStringId actionId in m_treeDesc.ActionIds)
            {
                if (!botActions.ContainsActionDesc(actionId))
                {
                    m_tmpHelper.Add(actionId);
                }
            }

            if (m_tmpHelper.Count > 0)
            {
                StringBuilder failText = new StringBuilder("Error! The behavior tree is not compatible with the bot. Missing bot actions: ");
                foreach (var action in m_tmpHelper)
                {
                    failText.Append(action.ToString());
                    failText.Append(", ");
                }
                System.Diagnostics.Debug.Fail(failText.ToString());
                m_tmpHelper.Clear();
                return false;
            }
            else
            {
                return true;
            }
        }
Exemple #15
0
        public ActionCollection GetInboundActions()
        {
            ActionCollection inboundActions = new ActionCollection();

            inboundActions.Add(new CMS.Core.Communication.Action("Sails", new string[0]));
            return(inboundActions);
        }
Exemple #16
0
        public bool IsCompatibleWithBot(ActionCollection botActions)
        {
            foreach (MyStringId actionId in m_treeDesc.ActionIds)
            {
                if (!botActions.ContainsActionDesc(actionId))
                {
                    m_tmpHelper.Add(actionId);
                }
            }

            if (m_tmpHelper.Count > 0)
            {
                StringBuilder failText = new StringBuilder("Error! The behavior tree is not compatible with the bot. Missing bot actions: ");
                foreach (var action in m_tmpHelper)
                {
                    failText.Append(action.ToString());
                    failText.Append(", ");
                }
                System.Diagnostics.Debug.Fail(failText.ToString());
                m_tmpHelper.Clear();
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #17
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <ActionInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <ActionInfo> list = new List <ActionInfo>();

            Query q = Action.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            ActionCollection collection = new  ActionCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Action action  in collection)
            {
                ActionInfo actionInfo = new ActionInfo();
                LoadFromDAL(actionInfo, action);
                list.Add(actionInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
        /// <summary>
        /// Initializes a new instance of the ModuleBlackboardServer class
        /// </summary>
        /// <param name="name">Module name</param>
        /// <param name="port">Port for accepting incoming connections</param>
        internal ModuleBlackboardServer(string name, int port)
        {
            if ((port < 1024) || (port > 65535))
            {
                throw new ArgumentException("Port must be between 1024 and 65535", "port");
            }
            if (!Regex.IsMatch(name, @"\w[\w\-_\d]{2,}"))
            {
                throw new ArgumentException("Invalid module name", "name");
            }
            this.name = name;
            this.port = port;
            this.busy = false;
            //this.waitingResponse = new List<Command>(10);
            //this.responses = new List<Response>();
            //this.commands = new List<Command>();
            this.prototypes         = new PrototypeCollection(this);
            this.lockList           = new List <Command>();
            this.restartActions     = new ActionCollection(this);
            this.restartTestActions = new ActionCollection(this);
            this.startupActions     = new ActionCollection(this);
            this.stopActions        = new ActionCollection(this);
            this.dataReceived       = new Queue <byte[]>(10);

            this.restartRequested     = false;
            this.restartTestRequested = false;
            this.simOptions           = SimulationOptions.SimulationDisabled;
        }
Exemple #19
0
 public void Init()
 {
     _taskServiceConvertorFactory = new Mock <ITaskServiceConvertorFactory>();
     _nativeService  = new TaskService();        //localhost
     _nativeTask     = _nativeService.NewTask(); //actually a definition , not an actual task
     _nativeInstance = _nativeTask.Actions;
 }
 public void AddMessageListener <T>(Action <T> callback) where T : Message
 {
     if (!_messageCallbacks.ContainsKey(typeof(T)))
     {
         _messageCallbacks[typeof(T)] = new ActionCollection <T>();
     }
     ((ActionCollection <T>)_messageCallbacks[typeof(T)]).Add(callback);
 }
        public void Test_Action_Collection_Default()
        {
            var sut = new ActionCollection();

            Fixture.AddManyTo(sut, 19);

            Assert.True(sut.Count == 19);
        }
Exemple #22
0
        public void VectorChanged_ActionChangedToNonAction_ExceptionThrown()
        {
            ActionCollection actionCollection = new ActionCollection();

            actionCollection.Add(new StubAction());

            Assert.ThrowsException <COMException>(() => actionCollection[0] = new Button());
        }
Exemple #23
0
        public void GenerateActions(ActionCollection actions, ActionItemCollection menu, ActionItemCollection toolbar)
        {
            //actions.Add("9px", "Use 9px Font|9px Font|Toggle the 9th pixel to emulate text mode", new EventHandler(Use9px));

            //ActionItemSubMenu aiFile = menu.AddSubMenu("&File");

            //aiFile.Actions.Add(actions["9px"]);
        }
Exemple #24
0
        public void VectorChanged_ActionChangedToNonAction_ExceptionThrown()
        {
            ActionCollection actionCollection = new ActionCollection();

            actionCollection.Add(new StubAction());

            TestUtilities.AssertThrowsException(() => actionCollection[0] = new Button());
        }
Exemple #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BridgeToUser"/> class.
 /// </summary>
 /// <param name="userId">User to bridge to.</param>
 public BridgeToUser(int userId)
 {
     UserId = userId;
     BusyActions = new ActionCollection();
     NotAvailableActions = new ActionCollection();
     NotRegisteredActions = new ActionCollection();
     TimeoutActions = new ActionCollection();
 }
Exemple #26
0
 public static void RefreshDataBindingsOnActions(ActionCollection actions)
 {
     foreach (DependencyObject current in actions)
     {
         foreach (DependencyProperty current2 in DataBindingHelper.GetDependencyProperties(current.GetType()))
             DataBindingHelper.RefreshBinding(current, current2);
     }
 }
        public void Init()
        {
            _taskServiceConvertorFactory = new Mock<ITaskServiceConvertorFactory>();
            _nativeService = new TaskService();//localhost
            _nativeTask = _nativeService.NewTask();//actually a definition , not an actual task
            _nativeInstance = _nativeTask.Actions;

        }
Exemple #28
0
        /// <summary>
        /// Creates the action map
        /// </summary>
        /// <returns>
        /// An array of Action objects describing the game action
        /// to device object map for this application
        /// </returns>
        private void CreateActionMap(ActionCollection map)
        {
            #region Step 2: Define the action map.
            // ****************************************************************************
            // Step 2: Define the action map.
            //
            // The action map instructs DirectInput on how to map game actions to device
            // objects. By selecting a predefined game genre that closely matches our game,
            // you can largely avoid dealing directly with device details. For this sample
            // we've selected the DIVIRTUAL_FIGHTING_HAND2HAND, and this constant will need
            // to be selected into the DIACTIONFORMAT structure later to inform DirectInput
            // of our choice. Every device has a mapping from genre actions to device
            // objects, so mapping your game actions to genre actions almost guarantees
            // an appropriate device configuration for your game actions.
            //
            // If DirectInput has already been given an action map for this GUID, it
            // will have created a user map for this application
            // (C:\Program Files\Common Files\DirectX\DirectInput\User Maps\*.ini). If a
            // map exists, DirectInput will use the action map defined in the stored user
            // map instead of the map defined in your program. This allows the user to
            // customize controls without losing changes when the game restarts. If you
            // wish to make changes to the default action map without changing the
            // GUID, you will need to delete the stored user map from your hard drive
            // for the system to detect your changes and recreate a stored user map.
            // ****************************************************************************
            #endregion

            // Device input (joystick, etc.) that is pre-defined by dinput according
            // to genre type. The genre for this app is Action->Hand to Hand Fighting.
            map.Add(CreateAction(GameActions.Walk, FightingHandToHand.AxisLateral, 0, "Walk left/right"));
            map.Add(CreateAction(GameActions.Block, FightingHandToHand.ButtonBlock, 0, "Block"));
            map.Add(CreateAction(GameActions.Kick, FightingHandToHand.ButtonKick, 0, "Kick"));
            map.Add(CreateAction(GameActions.Punch, FightingHandToHand.ButtonPunch, 0, "Punch"));
            map.Add(CreateAction(GameActions.TheDeAppetizer, FightingHandToHand.ButtonSpecial1, 0, "\"The De-Appetizer\""));

            // Map the apologize button to any button on the device. directInput
            // defines several "Any-Control Constants" for mapping game actions to
            // any device object of a particular type.
            map.Add(CreateAction(GameActions.Apologize, DInputHelper.ButtonAny(1), 0, "Apologize"));

            // Keyboard input mappings
            map.Add(CreateAction(GameActions.WalkLeft, Keyboard.Left, 0, "Walk left"));
            map.Add(CreateAction(GameActions.WalkRight, Keyboard.Right, 0, "Walk right"));
            map.Add(CreateAction(GameActions.Block, Keyboard.B, 0, "Block"));
            map.Add(CreateAction(GameActions.Kick, Keyboard.K, 0, "Kick"));
            map.Add(CreateAction(GameActions.Punch, Keyboard.P, 0, "Punch"));
            map.Add(CreateAction(GameActions.TheDeAppetizer, Keyboard.D, 0, "\"The De-Appetizer\""));
            map.Add(CreateAction(GameActions.Apologize, Keyboard.A, 0, "Apologize"));

            // The AppFixed constant can be used to instruct directInput that the
            // current mapping can not be changed by the user.
            map.Add(CreateAction(GameActions.Quit, Keyboard.Q, ActionAttributeFlags.AppFixed, "Quit"));

            // Mouse input mappings
            map.Add(CreateAction(GameActions.Walk, Mouse.XAxis, 0, "Walk"));
            map.Add(CreateAction(GameActions.Punch, Mouse.Button0, 0, "Punch"));
            map.Add(CreateAction(GameActions.Kick, Mouse.Button1, 0, "Kick"));
        }
        private void GenerateBehaviorActions(ActionCollection actionCollection, CodeTypeDeclaration classType, CodeMemberMethod method, CodeVariableReferenceExpression behaviorVarRef, string behaviorName)
        {
            for (int i = 0; i < actionCollection.Count; i++)
            {
                var    action     = actionCollection[i];
                string actionName = behaviorName + "_ACT_" + i;
                Type   type       = action.GetType();

                CodeVariableDeclarationStatement variable = new CodeVariableDeclarationStatement(type.Name, actionName, new CodeObjectCreateExpression(type.Name));
                method.Statements.Add(variable);
                var actionVarRef = new CodeVariableReferenceExpression(actionName);

                method.Statements.Add(new CodeMethodInvokeExpression(
                                          behaviorVarRef, "Actions.Add", actionVarRef));

                ValueGenerator valueGenerator      = new ValueGenerator();
                MethodInfo     generateFieldMethod = typeof(CodeComHelper).GetMethod("GenerateField");

                LocalValueEnumerator enumerator = action.GetLocalValueEnumerator();
                while (enumerator.MoveNext())
                {
                    LocalValueEntry    entry    = enumerator.Current;
                    DependencyProperty property = entry.Property;
                    Type valueType = entry.Value.GetType();
                    if (CodeComHelper.IsValidForFieldGenerator(entry.Value))
                    {
                        if (valueGenerator.Generators.ContainsKey(property.PropertyType) || valueGenerator.Generators.ContainsKey(valueType))
                        {
                            CodeExpression propValue = valueGenerator.ProcessGenerators(classType, method, entry.Value, actionName);
                            if (propValue != null)
                            {
                                method.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(actionVarRef, property.Name), propValue));
                            }
                        }
                        else if (entry.Value is PropertyPath)
                        {
                            PropertyPath path = entry.Value as PropertyPath;
                            method.Statements.Add(new CodeAssignStatement(
                                                      new CodeFieldReferenceExpression(actionVarRef, property.Name),
                                                      new CodeObjectCreateExpression("PropertyPath", new CodePrimitiveExpression(path.Path))));
                        }
                        else
                        {
                            MethodInfo generic = generateFieldMethod.MakeGenericMethod(property.PropertyType);
                            if (generic == null)
                            {
                                throw new NullReferenceException("Generic method not created for type - " + property.PropertyType);
                            }

                            generic.Invoke(null, new object[] { method, actionVarRef, action, property });
                        }
                    }
                }

                CodeComHelper.GenerateBindings(method, actionVarRef, action, actionName, behaviorVarRef);
                //CodeComHelper.GenerateResourceReferences(method, actionVarRef, action);
            }
        }
        public void ClearTest()
        {
            var collection = new ActionCollection();
            var action     = new MockAction("name", collection);

            Assert.That(collection.Contains("name"));
            collection.Clear();
            Assert.That(collection.Contains("name") == false);
        }
        /// <summary>
        ///   Creates all necessary collections for the AI. Note that the collections created by this
        ///   will in most instances be unique. If however, for some reason, there is the need for different
        ///   AI systems, then these should have separate collections.
        /// </summary>
        /// <returns></returns>
        public static IAiCollection Create()
        {
            var a = new ActionCollection();
            var c = new ConsiderationCollection();
            var o = new OptionCollection(a, c);
            var b = new BehaviourCollection(o);

            return(new AiCollection(b));
        }
        public void ContainsActionTest2()
        {
            var collection = new ActionCollection();
            var action     = new MockAction();

            action.NameId = "name";
            collection.Add(action);
            Assert.That(collection.Contains("name"));
        }
Exemple #33
0
 /// <summary>
 /// Initializes a new instance of the DetailMenu class.
 /// </summary>
 public DetailMenu(Micajah.Common.Pages.MasterPage masterPage, IList actionIdList, bool isFrameworkAdmin, bool isAuthenticated)
 {
     m_PrimaryMenuItems = new ActionCollection();
     m_OtherMenuItems   = new ActionCollection();
     m_MasterPage       = masterPage;
     m_ActionIdList     = actionIdList;
     m_IsFrameworkAdmin = isFrameworkAdmin;
     m_IsAuthenticated  = isAuthenticated;
 }
        public void AddActionTest()
        {
            var collection = new ActionCollection();
            var action     = new MockAction();

            action.NameId = "someaction";
            Assert.That(collection.Add(action));
            Assert.That(collection.Add(action) == false);
        }
 /// <summary>
 /// Ensures that all binding expression on actions are up to date.
 /// </summary>
 /// <remarks>
 /// DataTriggerBehavior fires during data binding phase. Since the ActionCollection is a child of the behavior,
 /// bindings on the action  may not be up-to-date. This routine is called before the action
 /// is executed in order to guarantee that all bindings are refreshed with the most current data.
 /// </remarks>
 public static void RefreshDataBindingsOnActions(ActionCollection actions)
 {
     foreach (DependencyObject action in actions)
     {
         foreach (DependencyProperty property in DataBindingHelper.GetDependencyProperties(action.GetType()))
         {
             DataBindingHelper.RefreshBinding(action, property);
         }
     }
 }
Exemple #36
0
 public void Dispose()
 {
     _regInfo = null;
     _triggers = null;
     _settings = null;
     _principal = null;
     _actions = null;
     if (_v2Def != null)
         Marshal.ReleaseComObject(_v2Def);
     _v1Task = null;
 }
        public ActionList()
        {
            this.actions = new ActionCollection(this);
            this.targets = new Dictionary<Component, Action>();
            this.typesDescription = new Dictionary<Type, ActionTargetDescriptionInfo>();
            this.enabled = true;
            this.tooltip = new ToolTip();

            if (!DesignMode)
                Application.Idle += new EventHandler(Application_Idle);
        }
            public ActionCollection GetActionCollection(Type controllerType)
            {
                ActionCollection actionCollection;

                if (_actionCollections.TryGetValue(controllerType, out actionCollection))
                    return actionCollection;

                lock (_lock)
                {
                    if (_actionCollections.TryGetValue(controllerType, out actionCollection))
                        return actionCollection;

                    actionCollection = new ActionCollection(controllerType);
                    _actionCollections.Add(controllerType, actionCollection);
                    return actionCollection;
                }
            }
Exemple #39
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<ActionInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(ActionInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< ActionInfo>;
     }
     else
     {
         List< ActionInfo>  list =new List< ActionInfo>();
         ActionCollection  collection=new  ActionCollection();
         Query qry = new Query(Action.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Action action in collection)
         {
             ActionInfo actionInfo= new ActionInfo();
             LoadFromDAL(actionInfo,action);
             list.Add(actionInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(ActionInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
 /// <summary>
 /// Load a group of actions for the provided module action list
 /// </summary>
 /// <param name="actionGroup">The name of the group of actions in the xml file</param>
 /// <param name="actionName">The name of the actions to load (trigger)</param>
 /// <param name="doc">The xml document from which the actions will be loaded</param>
 /// <param name="ac">The action list to load the actions within</param>
 /// <param name="log">The log writer</param>
 private static void LoadModuleActions(string actionGroup, string actionName, XmlDocument doc, ActionCollection ac, ILogWriter log)
 {
     if (doc.GetElementsByTagName(actionGroup).Count > 0)
         ac.AddRange(XtractActionList(doc.GetElementsByTagName(actionGroup)[0].ChildNodes));
     if (ac.Count > 0)
         log.WriteLine(2, "\t" + ac.Count.ToString() + " " + actionName + " actions added");
 }
 public IActionCollection CreateActionCollection(ActionCollection actionCollection)
 {
     return new Dev2ActionCollection(this, actionCollection);
 }
 private XElement CreateGMActionBranch( ActionCollection aActions )
 {
     return
     new XElement( "Actions",
       from action in aActions select
     new XElement( "Action",
       new XElement( "LibraryID", action.LibraryID ),
       CreateActionComment( action.LibraryID, action.ActionID ),
       new XElement( "ActionID", action.ActionID ),
       new XElement( "ActionKind", action.ActionKind ),
       new XElement( "ActionType", action.ActionType ),
       new XElement( "CanBeRelative", action.CanBeRelative ),
       new XElement( "ActionIsQuestion", action.ActionIsQuestion ),
       new XElement( "ActionIsApplyable", action.ActionIsApplyable ),
       new XElement( "FunctionName", action.FunctionName ),
       new XElement( "Code", action.Code ),
       new XComment( "Node below refers to: " + FindObjectName( m_gmk.Objects, action.ObjectApplied ) ),
       new XElement( "ObjectApplied", action.ObjectApplied ),
       new XElement( "IsRelative", action.IsRelative ),
       new XElement( "NegateCondition", action.NegateCondition ),
       new XElement( "Arguments",
         from argument in action.Arguments select
         new XElement( "Argument",
           new XElement( "Kind", argument.Kind.ToString() ),
           CreateArgumentResourceComment( argument ),
           new XElement( "Value", EscapeText( argument.Value ) )
         )
       )
     )
       );
 }
Exemple #43
0
    /// <summary>
    /// Constructeur
    /// </summary>
    public ActionList() {
      //Psl.Tracker.Tracker.Track( "ActionList.cctor.3 (empty)" );

      // initialisation dans tous les cas
      actions = new ActionCollection( this );

      // initialisations hors mode conception
      if (DesignMode) return;
      Application.Idle += new EventHandler( Application_Idle );
      ActionGlobalBeforeEvent += new ActionEventHandler( OnActionGlobalBefore );
      ActionGlobalAfterEvent += new ActionEventHandler( OnActionGlobalAfter );
    }
 /// <summary>
 /// Moves the run and check actions from the source ActionCollection to the destination ActionCollection
 /// </summary>
 private static void MoveActions(ActionCollection source, ActionCollection destination)
 {
     if ((source == null) || (destination == null))
         return;
     for (int i = 0; i < source.Count; ++i)
     {
         if ((source[i] is ActionRun) || (source[i] is ActionCheck))
         {
             destination.Add(source[i]);
             source.RemoveAt(i);
             --i;
         }
     }
 }
Exemple #45
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (!DesignMode)
                {
                    GlobalEvents.StaticIdle -= new EventHandler(OnIdle);
                    Menu = null;
                }
                if(components != null)
                {
                    components.Dispose();
                    components = null;
                }

                if(_toolTip != null)
                {
                    _toolTip.Dispose();
                    _toolTip = null;
                }

                if(_actions != null)
                {
                    _actions.Dispose();
                    _actions = null;
                }
            }
            base.Dispose( disposing );
        }
Exemple #46
0
		public GenerateActionArgs(ActionCollection actions, ActionItemCollection menu, ActionItemCollection toolBar)
		{
			this.actions = actions;
			this.menu = menu;
			this.toolBar = toolBar;
		}
Exemple #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DialPlan"/> class.
 /// </summary>
 public DialPlan(Contact from, Contact to)
 {
     Caller = from;
     Destination = to;
     Actions = new ActionCollection();
 }
Exemple #48
0
		public GenerateActionArgs(Generator g, Control control)
		{
			this.actions = new ActionCollection(g, control);
			this.menu = new ActionItemCollection(actions);
			this.toolBar = new ActionItemCollection(actions);
		}
Exemple #49
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< ActionInfo> pList, ActionCollection pCollection)
 {
     foreach (Action action in pCollection)
     {
         ActionInfo actionInfo = new ActionInfo();
         LoadFromDAL(actionInfo, action );
         pList.Add(actionInfo);
     }
 }
Exemple #50
0
 /// <summary>
 /// Common code for initialising the instance
 /// </summary>
 private void Init()
 {
     _actions = new ActionCollection(this);
     if (!DesignMode)
     {
         GlobalEvents.StaticIdle += new EventHandler(OnIdle);
     }
 }
Exemple #51
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ActionInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ActionInfo> list = new List< ActionInfo>();

            Query q = Action .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ActionCollection  collection=new  ActionCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Action  action  in collection)
            {
                ActionInfo actionInfo = new ActionInfo();
                LoadFromDAL(actionInfo,   action);
                list.Add(actionInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
        private void GenerateBehaviorActions(ActionCollection actionCollection, CodeTypeDeclaration classType, CodeMemberMethod method, CodeVariableReferenceExpression behaviorVarRef, string behaviorName)
        {
            for (int i = 0; i < actionCollection.Count; i++)
            {
                var action = actionCollection[i];
                string actionName = behaviorName + "_ACT_" + i;
                Type type = action.GetType();

                CodeVariableDeclarationStatement variable = new CodeVariableDeclarationStatement(type.Name, actionName, new CodeObjectCreateExpression(type.Name));
                method.Statements.Add(variable);
                var actionVarRef = new CodeVariableReferenceExpression(actionName);

                method.Statements.Add(new CodeMethodInvokeExpression(
                        behaviorVarRef, "Actions.Add", actionVarRef));

                ValueGenerator valueGenerator = new ValueGenerator();
                MethodInfo generateFieldMethod = typeof(CodeComHelper).GetMethod("GenerateField");

                LocalValueEnumerator enumerator = action.GetLocalValueEnumerator();
                while (enumerator.MoveNext())
                {
                    LocalValueEntry entry = enumerator.Current;
                    DependencyProperty property = entry.Property;
                    Type valueType = entry.Value.GetType();
                    if (CodeComHelper.IsValidForFieldGenerator(entry.Value))
                    {
                        if (valueGenerator.Generators.ContainsKey(property.PropertyType) || valueGenerator.Generators.ContainsKey(valueType))
                        {
                            CodeExpression propValue = valueGenerator.ProcessGenerators(classType, method, entry.Value, actionName);
                            if (propValue != null)
                            {
                                method.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(actionVarRef, property.Name), propValue));
                            }
                        }
                        else if (entry.Value is PropertyPath)
                        {
                            PropertyPath path = entry.Value as PropertyPath;
                            method.Statements.Add(new CodeAssignStatement(
                                new CodeFieldReferenceExpression(actionVarRef, property.Name), 
                                new CodeObjectCreateExpression("PropertyPath", new CodePrimitiveExpression(path.Path))));
                        }
                        else
                        {
                            MethodInfo generic = generateFieldMethod.MakeGenericMethod(property.PropertyType);
                            if (generic == null)
                            {
                                throw new NullReferenceException("Generic method not created for type - " + property.PropertyType);
                            }

                            generic.Invoke(null, new object[] { method, actionVarRef, action, property });
                        }
                    }
                }

                CodeComHelper.GenerateBindings(method, actionVarRef, action, actionName, behaviorVarRef);
                //CodeComHelper.GenerateResourceReferences(method, actionVarRef, action);
            }
        }
 public Dev2ActionCollection(ITaskServiceConvertorFactory taskServiceConvertorFactory,
     ActionCollection nativeInstance)
 {
     _taskServiceConvertorFactory = taskServiceConvertorFactory;
     _nativeInstance = nativeInstance;
 }
        /// <summary>
        /// Initializes a new instance of the Module class
        /// </summary>
        /// <param name="name">Module name</param>
        protected ModuleClient(string name)
        {
            this.name = name;
            this.alias = name;
            this.busy = false;
            this.ready = false;
            this.enabled = true;
            this.checkInterval = GlobalCheckInterval;
            this.executableInfo = new ModuleProcessInfo();
            //this.waitingResponse = new List<Command>(10);
            //this.responses = new List<Response>();
            //this.commands = new List<Command>();
            this.prototypes = new PrototypeCollection(this);
            this.lockList = new List<Command>();
            this.restartActions = new ActionCollection(this);
            this.restartTestActions = new ActionCollection(this);
            this.startupActions = new ActionCollection(this);
            this.stopActions = new ActionCollection(this);
            this.testTimeOutActions = new ActionCollection(this);

            this.restartRequested = false;
            this.restartTestRequested = false;
            this.rnd = new Random(name.GetHashCode());
            this.simOptions = ModuleSimulationOptions.SimulationDisabled;

            // Shared Variable related prototypes
            this.Prototypes.Add(Prototype.CreateVar);
            this.Prototypes.Add(Prototype.ListVars);
            this.Prototypes.Add(Prototype.Prototypes);
            this.Prototypes.Add(Prototype.ReadVar);
            this.Prototypes.Add(Prototype.ReadVars);
            this.Prototypes.Add(Prototype.StatVar);
            this.Prototypes.Add(Prototype.WriteVar);

            this.readyEvent = new ManualResetEvent(false);
        }
Exemple #55
0
Fichier : Task.cs Projet : kmpm/MoJ
 public Task()
 {
     _actions = new ActionCollection();
 }
Exemple #56
0
		public ActionItemSubMenu(ActionCollection actions, string subMenuText)
		{
			this.Actions = new ActionItemCollection(actions);
			this.SubMenuText = subMenuText;
		}
		void DoActions (IScriptObject owner, ActionCollection Actions)
		{
			Assert.AreEqual (owner, ((IScriptObject)Actions).Owner, "a1");
			Assert.AreEqual (0, Actions.Count, "a2");
		}
Exemple #58
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     regInfo = null;
     triggers = null;
     settings = null;
     principal = null;
     actions = null;
     if (v2Def != null) Marshal.ReleaseComObject(v2Def);
     v1Task = null;
 }