예제 #1
0
        private IResource[] GetFilterResources(IResource workspace)
        {
            ArrayList result = ArrayListPool.Alloc();

            try
            {
                IResourceList resources = workspace.GetLinksTo(null, Props.InWorkspace).Union(
                    workspace.GetLinksTo(null, Props.InWorkspaceRecursive));
                foreach (IResource res in resources)
                {
                    WorkspaceTypeRec rec = (WorkspaceTypeRec)_resTypeToWorkspaceRec [res.Type];
                    if (rec != null && rec._workspaceResType == WorkspaceResourceType.Filter)
                    {
                        result.Add(res);
                    }
                }
                if (result.Count == 0)
                {
                    return(null);
                }
                return((IResource[])result.ToArray(typeof(IResource)));
            }
            finally
            {
                ArrayListPool.Dispose(result);
            }
        }
예제 #2
0
        /**
         * Optimizes the predicate to make its calculation more efficient.
         */

        internal override ResourceListPredicate Optimize(bool isLive)
        {
            bool      optimized        = false;
            ArrayList newPredicateList = ArrayListPool.Alloc();

            try
            {
                ExpandIntersections(newPredicateList, ref optimized);
                RemoveEqualSources(newPredicateList, ref optimized);
                RemoveIntersectingUnions(newPredicateList, ref optimized);
                RemoveRedundantTypeIntersections(newPredicateList, ref optimized);
                ResourceListPredicate result = this;
                if (optimized)
                {
                    if (newPredicateList.Count == 1)
                    {
                        result = (ResourceListPredicate)newPredicateList [0];
                    }
                    else
                    {
                        _sourcePredicates = (ResourceListPredicate[])newPredicateList.ToArray(
                            typeof(ResourceListPredicate));
                    }
                }
                return(OptimizeSourcePredicates(result, isLive));
            }
            finally
            {
                ArrayListPool.Dispose(newPredicateList);
            }
        }
예제 #3
0
        private static void ParseQuotedPrintable(string charset, string text, StringBuilder output)
        {
            Encoding encoding = GetEncodingExceptionSafe(charset);

            string[] lines = text.Split('\n');
            bool     wrap  = true;

            ArrayList bytes = ArrayListPool.Alloc();

            try
            {
                for (int i = 0; i < lines.Length; ++i)
                {
                    if (!wrap)
                    {
                        bytes.Add((byte)'\n');
                    }
                    string line    = lines[i];
                    int    lineLen = line.Length;
                    for (int j = 0; j < lineLen; ++j)
                    {
                        char c = line[j];
                        if (c != '=')
                        {
                            wrap = false;
                            bytes.Add((byte)c);
                        }
                        else
                        {
                            wrap = true;
                            if (++j < lineLen - 1 && line[j] != '\r')
                            {
                                try
                                {
                                    bytes.Add(Convert.ToByte(line.Substring(j, 2), 16));
                                    wrap = false;
                                }
                                catch (Exception)
                                {
                                    // just ignore any unparsable garbage
                                }
                            }
                            ++j;
                        }
                    }
                }
                output.Append(encoding.GetString((byte[])bytes.ToArray(typeof(byte))));
            }
            catch
            {
                output.Append(text);
            }
            finally
            {
                ArrayListPool.Dispose(bytes);
            }
        }
예제 #4
0
        public static byte[] DecodeQuotedPrintable(string text)
        {
            ArrayList bytes = ArrayListPool.Alloc();

            try
            {
                string[] lines = text.Split('\n');

                for (int i = 0; i < lines.Length; ++i)
                {
                    if (i > 0)
                    {
                        bytes.Add((byte)'\n');
                    }
                    char[] chars   = lines[i].ToCharArray();
                    int    lineLen = chars.Length;
                    for (int j = 0; j < lineLen; ++j)
                    {
                        char c = chars[j];
                        if (c != '=')
                        {
                            bytes.Add((byte)c);
                        }
                        else
                        {
                            if (++j < lineLen - 1 && chars[j] != '\r')
                            {
                                try
                                {
                                    bytes.Add(Convert.ToByte(new string( chars, j, 2 ), 16));
                                }
                                catch (Exception)
                                {
                                    // just ignore any unparsable garbage
                                }
                            }
                            ++j;
                        }
                    }
                }
                return((byte[])bytes.ToArray(typeof(byte)));
            }
            finally
            {
                ArrayListPool.Dispose(bytes);
            }
        }
예제 #5
0
        private ResourceListPredicate OptimizePlainLists()
        {
            ArrayList predicates = ArrayListPool.Alloc();

            try
            {
                PlainListPredicate plainList = new PlainListPredicate(new IntArrayList());
                for (int i = 0; i < _sourcePredicates.Length; i++)
                {
                    PlainListPredicate sourcePlainList = _sourcePredicates [i] as PlainListPredicate;
                    if (sourcePlainList != null)
                    {
                        if (sourcePlainList.Count > 0)
                        {
                            bool sortedById;
                            plainList.AddRange(sourcePlainList.GetMatchingResources(out sortedById));
                        }
                    }
                    else
                    {
                        predicates.Add(_sourcePredicates [i]);
                    }
                }

                if (predicates.Count == 0)
                {
                    return(plainList);
                }

                if (plainList.Count > 0)
                {
                    predicates.Add(plainList);
                }

                if (predicates.Count == 1)
                {
                    return((ResourceListPredicate)predicates [0]);
                }

                _sourcePredicates = (ResourceListPredicate[])predicates.ToArray(typeof(ResourceListPredicate));
            }
            finally
            {
                ArrayListPool.Dispose(predicates);
            }
            return(this);
        }
예제 #6
0
파일: UnreadManager.cs 프로젝트: mo5h/omeo
        /// <summary>
        /// Returns the array of existing unread states in which the specified
        /// resource is visible.
        /// </summary>
        private UnreadState[] GetResourceUnreadStates(IResource res)
        {
            ArrayList states = ArrayListPool.Alloc();

            try
            {
                IResourceList workspaces = _workspaceManager.GetResourceWorkspaces(res);
                FillStatesForTab(states, workspaces, _tabProvider.GetDefaultTab());
                string tab = _tabProvider.GetResourceTab(res);
                if (tab != null)
                {
                    FillStatesForTab(states, workspaces, tab);
                }
                return((UnreadState[])states.ToArray(typeof(UnreadState)));
            }
            finally
            {
                ArrayListPool.Dispose(states);
            }
        }
예제 #7
0
        internal void ExpandParents(JetListViewNode node)
        {
            ArrayList nodes = ArrayListPool.Alloc();

            try
            {
                JetListViewNode theParent = node.Parent;
                while (theParent != null && theParent != Root)
                {
                    nodes.Insert(0, theParent);
                    theParent = theParent.Parent;
                }
                foreach (JetListViewNode n in nodes)
                {
                    n.Expanded = true;
                }
            }
            finally
            {
                ArrayListPool.Dispose(nodes);
            }
        }
예제 #8
0
        protected override void AddResourceNodes()
        {
            _conversationNodeMap = new IntHashTable();
            foreach (IResource res in _resourceList.ValidResources)
            {
                ConversationNode node = GetConversationNode(res);
                node.InList = true;
            }

            ArrayList topLevelNodes = ArrayListPool.Alloc();

            try
            {
                foreach (ConversationNode node in _conversationRoots)
                {
                    FillTopLevelNodes(topLevelNodes, node);
                }
                if (_lastComparer != null)
                {
                    topLevelNodes.Sort(new ConversationNodeComparer(_lastComparer));
                }

                foreach (ConversationNode node in topLevelNodes)
                {
                    JetListViewNode lvNode = AddListViewNode(_listView.Nodes, node);
                    if (node.Children != null || _threadingHandler.CanExpandThread(node.Resource, ThreadExpandReason.Expand))
                    {
                        lvNode.HasChildren = true;
                    }
                }
            }
            finally
            {
                ArrayListPool.Dispose(topLevelNodes);
            }

            _listView.ChildrenRequested += HandleChildrenRequested;
            _listView.NodeCollection.NodeExpandChanging += HandleExpandChanging;
        }
예제 #9
0
파일: ResourceList.cs 프로젝트: mo5h/omeo
        /**
         * Returns the array containing all resource types currently contained in
         * the resource list.
         */

        public string[] GetAllTypes()
        {
            lock (this)
            {
                Instantiate();
                if (_predicate.GetKnownType() >= 0)
                {
                    return(new string[] { MyPalStorage.Storage.ResourceTypes [_predicate.GetKnownType()].Name });
                }
                if (Count > 0)
                {
                    if (Count == 1)
                    {
                        return(new string[] { this [0].Type });
                    }

                    HashSet   processedTypes = new HashSet();
                    ArrayList resTypeList    = ArrayListPool.Alloc();
                    try
                    {
                        foreach (IResource res in ValidResources)
                        {
                            if (!processedTypes.Contains(res.Type))
                            {
                                processedTypes.Add(res.Type);
                                resTypeList.Add(res.Type);
                            }
                        }
                        resTypeList.Sort();
                        return((string[])resTypeList.ToArray(typeof(string)));
                    }
                    finally
                    {
                        ArrayListPool.Dispose(resTypeList);
                    }
                }
            }
            return(emptyStringArray);
        }
예제 #10
0
        internal void Remove(object item, JetListViewNode parentNode)
        {
            object nodeItem = _nodeMap [item];

            if (nodeItem != null)
            {
                if (nodeItem is JetListViewNode)
                {
                    _nodeMap.Remove(item);
                }
                else
                {
                    JetListViewNode[] nodes    = (JetListViewNode[])nodeItem;
                    ArrayList         newNodes = ArrayListPool.Alloc();
                    try
                    {
                        for (int src = 0; src < nodes.Length; src++)
                        {
                            if (nodes [src].Parent != parentNode)
                            {
                                newNodes.Add(nodes [src]);
                            }
                        }
                        if (newNodes.Count == 1)
                        {
                            _nodeMap [item] = newNodes [0];
                        }
                        else
                        {
                            _nodeMap [item] = (JetListViewNode[])newNodes.ToArray(typeof(JetListViewNode));
                        }
                    }
                    finally
                    {
                        ArrayListPool.Dispose(newNodes);
                    }
                }
            }
        }
예제 #11
0
        public void ResourceNodeSelected(IResource res)
        {
            IResource workspace = res.GetLinkProp("InWorkspace");

            if (workspace != null)
            {
                if (_lastWorkspace != workspace)
                {
                    _resList = _workspaceManager.GetResourcesOutsideContainers(workspace);
                    SetWorkspaceWatchList(workspace);
                }
                else if (_workspaceChanged)
                {
                    _resList = _workspaceManager.GetResourcesOutsideContainers(workspace);
                }

                string[]  resTypesArray;
                ArrayList nonInternalTypes = ArrayListPool.Alloc();
                try
                {
                    foreach (IResourceType rt in Core.ResourceStore.ResourceTypes)
                    {
                        if (!rt.HasFlag(ResourceTypeFlags.Internal))
                        {
                            nonInternalTypes.Add(rt.Name);
                        }
                    }
                    resTypesArray = (string[])nonInternalTypes.ToArray(typeof(string));
                }
                finally
                {
                    ArrayListPool.Dispose(nonInternalTypes);
                }
                _resList = _resList.Intersect(Core.ResourceStore.GetAllResources(resTypesArray), true);
                Core.ResourceBrowser.DisplayResourceList(res, _resList,
                                                         "Resources in " + workspace.GetPropText(Core.Props.Name),
                                                         null);
            }
        }