コード例 #1
0
 public View(string name, object control, string caption, OnClosingDelegate onClosingHandler, ActivateDelegate onActivateHandler, BooleanDelegate canCloseHandler, string hint, Image image, ViewDockingState dockingState, ViewDockingStateFlagExt allowDockingStates)
     : base(name, control, caption, hint, image)
 {
     _onCloseHandler    = onClosingHandler;
     _canCloseHandler   = canCloseHandler;
     _onActivateHandler = onActivateHandler;
 }
コード例 #2
0
 public static bool Any <T>(this List <T> l, BooleanDelegate <T> condition)
 {
     foreach (T t in l)
     {
         if (condition(t))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #3
0
        public static List <T> Where <T>(this List <T> l, BooleanDelegate <T> condition)     //now THIS one is useful. probably the same as the official version.
        {
            List <T> result = new List <T>();

            foreach (T t in l)
            {
                if (condition(t))
                {
                    result.Add(t);
                }
            }
            return(result);
        }
コード例 #4
0
        public Command(string caption, ExecuteDelegate executeHandler, BooleanDelegate isEnabledHandler, string name, BooleanDelegate isVisibleHandler,
                       BooleanDelegate isCheckedHandler, string hint, Image image, CommandType commandType)
        {
            if (_commandType != UI.CommandType.Group && executeHandler == null)
            {
                throw new ArgumentNullException("No executeHandler");
            }

            _caption          = caption;
            _executeHandler   = executeHandler;
            _isEnabledHandler = isEnabledHandler;
            _name             = name;
            _isVisibleHandler = isVisibleHandler;
            _isCheckedHandler = isCheckedHandler;
            _hint             = hint;
            _image            = image;
            _commandType      = commandType;
        }
コード例 #5
0
ファイル: DllUtils.cs プロジェクト: N1ghtF1re/MPP-Labs
        public IDictionary <string, List <string> > GetTypes(BooleanDelegate filter)
        {
            var typesMap = new SortedDictionary <string, List <string> >();

            foreach (var type in _dll.GetExportedTypes())
            {
                InitializeNameSpace(typesMap, type.Namespace);
                var list = typesMap[type.Namespace];

                if (filter(type))
                {
                    Logger.Info("Adding type " + type.FullName);
                    list.Add(type.Name);
                }
                else
                {
                    Logger.Info("Found type which doesn't match to conditions' " + type.FullName);
                }
            }

            return(typesMap);
        }
コード例 #6
0
        public bool AddGroupRole(UUID groupID, UUID roleID, string description, string name, ulong powers, string title, BooleanDelegate d)
        {
            if (d())
            {
                GroupRolesData role = new GroupRolesData();
                role.Description = description;
                role.Members = 0;
                role.Name = name;
                role.Powers = powers;
                role.RoleID = roleID;
                role.Title = title;

                lock (m_Cache)
                {
                    m_Cache.AddOrUpdate("role-" + roleID.ToString(), role, GROUPS_CACHE_TIMEOUT);

                    // also remove this list
                    if (m_Cache.Contains("roles-" + groupID.ToString()))
                        m_Cache.Remove("roles-" + groupID.ToString());

                }

                return true;
            }

            return false;
        }
コード例 #7
0
        public bool UpdateGroupRole(UUID groupID, UUID roleID, string name, string description, string title, ulong powers, BooleanDelegate d)
        {
            if (d())
            {
                object role;
                lock (m_Cache)
                    if (m_Cache.TryGetValue("role-" + roleID.ToString(), out role))
                    {
                        GroupRolesData r = (GroupRolesData)role;
                        r.Description = description;
                        r.Name        = name;
                        r.Powers      = powers;
                        r.Title       = title;

                        m_Cache.Update("role-" + roleID.ToString(), r, GROUPS_CACHE_TIMEOUT);
                    }
                return(true);
            }
            else
            {
                lock (m_Cache)
                {
                    if (m_Cache.Contains("role-" + roleID.ToString()))
                    {
                        m_Cache.Remove("role-" + roleID.ToString());
                    }

                    // also remove these lists, because they will have an outdated role
                    if (m_Cache.Contains("roles-" + groupID.ToString()))
                    {
                        m_Cache.Remove("roles-" + groupID.ToString());
                    }
                }

                return(false);
            }
        }
コード例 #8
0
        public void RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    // update the cached role
                    string cacheKey = "role-" + RoleID.ToString();
                    object obj;
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        GroupRolesData r = (GroupRolesData)obj;
                        r.Members--;
                    }

                    cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();
                    if (m_Cache.Contains(cacheKey))
                    {
                        m_Cache.Remove(cacheKey);
                    }

                    cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString();
                    if (m_Cache.Contains(cacheKey))
                    {
                        m_Cache.Remove(cacheKey);
                    }
                }
            }
        }
コード例 #9
0
 public int ForEachOrthDirection(int r,int c,BooleanDelegate condition,bool OOB_automatically_passes)
 {
     int result = 0;
     for(int i=2;i<=8;i+=2){
         if(BoundsCheck(r,c)){
             if(condition(Map(PosInDir(r,c,i)))){
                 ++result;
             }
         }
         else{
             if(OOB_automatically_passes){
                 ++result;
             }
         }
     }
     return result;
 }
コード例 #10
0
        public void RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    // update the cached role
                    string cacheKey = "role-" + RoleID.ToString();
                    object obj;
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        GroupRolesData r = (GroupRolesData)obj;
                        r.Members--;
                    }

                    cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();
                    if (m_Cache.Contains(cacheKey))
                        m_Cache.Remove(cacheKey);

                    cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString();
                    if (m_Cache.Contains(cacheKey))
                        m_Cache.Remove(cacheKey);
                }
            }
        }
コード例 #11
0
        public void AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    // update the cached role
                    string cacheKey = "role-" + RoleID.ToString();
                    object obj;
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        GroupRolesData r = (GroupRolesData)obj;
                        r.Members++;
                    }

                    // add this agent to the list of role members
                    cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString();
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        try
                        {
                            // This may throw an exception, in which case the agentID is not a UUID but a full ID
                            // In that case, let's just remove the whoe things from the cache
                            UUID id = new UUID(AgentID);
                            List <ExtendedGroupRoleMembersData> xx     = (List <ExtendedGroupRoleMembersData>)obj;
                            List <GroupRoleMembersData>         rmlist = xx.ConvertAll <GroupRoleMembersData>(m_ForeignImporter.ConvertGroupRoleMembersData);
                            GroupRoleMembersData rm = new GroupRoleMembersData();
                            rm.MemberID = id;
                            rm.RoleID   = RoleID;
                            rmlist.Add(rm);
                        }
                        catch
                        {
                            m_Cache.Remove(cacheKey);
                        }
                    }

                    // Remove the cached info about this agent's roles
                    // because we don't have enough local info about the new role
                    cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();
                    if (m_Cache.Contains(cacheKey))
                    {
                        m_Cache.Remove(cacheKey);
                    }
                }
            }
        }
コード例 #12
0
 public Command(string caption, ExecuteDelegate executeHandler, BooleanDelegate isEnabledHandler)
     : this(caption, executeHandler, isEnabledHandler, null, null, null, string.Empty, null, UI.CommandType.Button)
 {
 }
コード例 #13
0
 /*public delegate void ArrayDelegate(string[,] map);
 public void ForEachRoom(ArrayDelegate action){
 }*/
 public static int ForEachDirection(string[,] map,int r,int c,BooleanDelegate condition,bool OOB_automatically_passes)
 {
     int result = 0;
     for(int i=1;i<=8;++i){
         int dir = i;
         if(dir == 5){
             dir = 9;
         }
         if(BoundsCheck(r,c,map.GetLength(0),map.GetLength(1))){
             pos p = PosInDir(r,c,dir);
             if(condition(map[p.r,p.c])){
                 ++result;
             }
         }
         else{
             if(OOB_automatically_passes){
                 ++result;
             }
         }
     }
     return result;
 }
コード例 #14
0
        public bool UpdateGroupRole(UUID groupID, UUID roleID, string name, string description, string title, ulong powers, BooleanDelegate d)
        {
            if (d())
            {
                object role;
                lock (m_Cache)
                    if (m_Cache.TryGetValue("role-" + roleID.ToString(), out role))
                    {
                        GroupRolesData r = (GroupRolesData)role;
                        r.Description = description;
                        r.Name = name;
                        r.Powers = powers;
                        r.Title = title;

                        m_Cache.Update("role-" + roleID.ToString(), r, GROUPS_CACHE_TIMEOUT);
                    }
                return true;
            }
            else
            {
                lock (m_Cache)
                {
                    if (m_Cache.Contains("role-" + roleID.ToString()))
                        m_Cache.Remove("role-" + roleID.ToString());

                    // also remove these lists, because they will have an outdated role
                    if (m_Cache.Contains("roles-" + groupID.ToString()))
                        m_Cache.Remove("roles-" + groupID.ToString());

                }

                return false;
            }
        }
コード例 #15
0
        public bool AddGroupNotice(UUID groupID, UUID noticeID, GroupNoticeInfo notice, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    m_Cache.AddOrUpdate("notice-" + noticeID.ToString(), notice, GROUPS_CACHE_TIMEOUT);
                    string cacheKey = "notices-" + groupID.ToString();
                    if (m_Cache.Contains(cacheKey))
                    {
                        m_Cache.Remove(cacheKey);
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #16
0
        public void AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    // update the cached role
                    string cacheKey = "role-" + RoleID.ToString();
                    object obj;
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        GroupRolesData r = (GroupRolesData)obj;
                        r.Members++;
                    }

                    // add this agent to the list of role members
                    cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString();
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        try
                        {
                            // This may throw an exception, in which case the agentID is not a UUID but a full ID
                            // In that case, let's just remove the whoe things from the cache
                            UUID id = new UUID(AgentID);
                            List<ExtendedGroupRoleMembersData> xx = (List<ExtendedGroupRoleMembersData>)obj;
                            List<GroupRoleMembersData> rmlist = xx.ConvertAll<GroupRoleMembersData>(m_ForeignImporter.ConvertGroupRoleMembersData);
                            GroupRoleMembersData rm = new GroupRoleMembersData();
                            rm.MemberID = id;
                            rm.RoleID = RoleID;
                            rmlist.Add(rm);
                        }
                        catch
                        {
                            m_Cache.Remove(cacheKey);
                        }
                    }

                    // Remove the cached info about this agent's roles
                    // because we don't have enough local info about the new role
                    cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();
                    if (m_Cache.Contains(cacheKey))
                        m_Cache.Remove(cacheKey);

                }
            }
        }
コード例 #17
0
        public bool AddGroupRole(UUID groupID, UUID roleID, string description, string name, ulong powers, string title, BooleanDelegate d)
        {
            if (d())
            {
                GroupRolesData role = new GroupRolesData();
                role.Description = description;
                role.Members     = 0;
                role.Name        = name;
                role.Powers      = powers;
                role.RoleID      = roleID;
                role.Title       = title;

                lock (m_Cache)
                {
                    m_Cache.AddOrUpdate("role-" + roleID.ToString(), role, GROUPS_CACHE_TIMEOUT);

                    // also remove this list
                    if (m_Cache.Contains("roles-" + groupID.ToString()))
                    {
                        m_Cache.Remove("roles-" + groupID.ToString());
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #18
0
        public bool AddGroupNotice(UUID groupID, UUID noticeID, GroupNoticeInfo notice, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    m_Cache.AddOrUpdate("notice-" + noticeID.ToString(), notice, GROUPS_CACHE_TIMEOUT);
                    string cacheKey = "notices-" + groupID.ToString();
                    if (m_Cache.Contains(cacheKey))
                        m_Cache.Remove(cacheKey);

                }

                return true;
            }

            return false;
        }
コード例 #19
0
 public int ForEachDirection(int r,int c,BooleanDelegate condition,bool OOB_automatically_passes)
 {
     int result = 0;
     for(int i=1;i<=8;++i){
         int dir = i;
         if(dir == 5){
             dir = 9;
         }
         if(BoundsCheck(r,c)){
             if(condition(Map(PosInDir(r,c,dir)))){
                 ++result;
             }
         }
         else{
             if(OOB_automatically_passes){
                 ++result;
             }
         }
     }
     return result;
 }