System.Security.Permissions.ResourcePermissionBase.UnionOfContents C# (CSharp) Méthode

UnionOfContents() private méthode

private UnionOfContents ( object currentContent, object targetContent ) : object
currentContent object
targetContent object
Résultat object
        private object UnionOfContents(object currentContent, object targetContent) {
            if (currentContent is int) {
                int currentAccess = (int)currentContent;
                int targetAccess = (int)targetContent;
                return (currentAccess | targetAccess);
            }
            else {
                //The wildcard and "." entries can be merged as
                //any other entry.
                Hashtable newContents = CreateHashtable();
                IDictionaryEnumerator contentEnumerator = ((Hashtable)currentContent).GetEnumerator();
                IDictionaryEnumerator targetContentEnumerator = ((Hashtable)targetContent).GetEnumerator();
                while(contentEnumerator.MoveNext())
                    newContents[(string)contentEnumerator.Key] = contentEnumerator.Value;

                while(targetContentEnumerator.MoveNext()) {
                    if (!newContents.ContainsKey(targetContentEnumerator.Key))
                        newContents[targetContentEnumerator.Key] = targetContentEnumerator.Value;
                    else {
                        object currentValue = newContents[targetContentEnumerator.Key];
                        object targetValue =targetContentEnumerator.Value;
                        newContents[targetContentEnumerator.Key] = UnionOfContents(currentValue, targetValue);
                    }
                }

                return (newContents.Count > 0) ? newContents : null;
            }
        }