コード例 #1
0
ファイル: Restrictions.cs プロジェクト: mo5h/omeo
        /// <summary>
        /// Deletes all restrictions on the specified property type.
        /// </summary>
        /// <param name="propId">The ID of the property type.</param>
        internal static void DeletePropRestrictions(int propId)
        {
            lock ( _restrictions )
            {
                foreach (HashMap.Entry e in _restrictions)
                {
                    ArrayList restrictionsToDelete = new ArrayList();
                    HashSet   restrictionsSet      = (HashSet)e.Value;
                    foreach (HashSet.Entry restrictionEntry in restrictionsSet)
                    {
                        ResourceRestriction restriction = (ResourceRestriction)restrictionEntry.Key;
                        if (restriction.PropId == propId)
                        {
                            restrictionsToDelete.Add(restriction);
                        }
                    }

                    foreach (ResourceRestriction restriction in restrictionsToDelete)
                    {
                        restrictionsSet.Remove(restriction);
                        restriction.DeleteFromResourceStore();
                    }
                }
            }
        }
コード例 #2
0
ファイル: Restrictions.cs プロジェクト: mo5h/omeo
 private static bool AddResourceRestriction(ResourceRestriction restriction)
 {
     lock ( _restrictions )
     {
         HashMap.Entry E = _restrictions.GetEntry(restriction.ResourceType);
         HashSet       restrictionsSet = (E == null) ?  new HashSet() : (HashSet)E.Value;
         if (!restrictionsSet.Contains(restriction))
         {
             restrictionsSet.Add(restriction);
             if (E == null)
             {
                 _restrictions[restriction.ResourceType] = restrictionsSet;
             }
             return(true);
         }
         return(false);
     }
 }
コード例 #3
0
ファイル: Restrictions.cs プロジェクト: mo5h/omeo
 public static void CheckResource(IResource res, IPropertyChangeSet changeSet)
 {
     if (_active)
     {
         lock ( _restrictions )
         {
             HashSet restrictionsSet = (HashSet)_restrictions[res.Type];
             if (restrictionsSet != null)
             {
                 foreach (HashSet.Entry E in restrictionsSet)
                 {
                     ResourceRestriction restriction = (ResourceRestriction)E.Key;
                     if ((restriction.PropId != ResourceProps.Id && changeSet.IsNewResource) ||
                         changeSet.IsPropertyChanged(restriction.PropId))
                     {
                         restriction.CheckResource(res, changeSet);
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: Restrictions.cs プロジェクト: mo5h/omeo
 private static LinkRestriction FindLinkRestriction(string fromResourceType, int linkType)
 {
     lock ( _restrictions )
     {
         HashSet restrictionsSet = (HashSet)_restrictions[fromResourceType];
         if (restrictionsSet != null)
         {
             foreach (HashSet.Entry E in restrictionsSet)
             {
                 ResourceRestriction restriction = (ResourceRestriction)E.Key;
                 if (restriction.PropId == linkType)
                 {
                     LinkRestriction lr = restriction as LinkRestriction;
                     if (lr != null)
                     {
                         return(lr);
                     }
                 }
             }
         }
         return(null);
     }
 }