Пример #1
0
 public int GetIndexByRuleId(RuleId id)
 {
     this.CheckSaved();
     if (id == null)
     {
         ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Rules::Bind. {0} should not be null.", "id");
         throw new ArgumentNullException(ServerStrings.ExNullParameter("id", 1));
     }
     if (id.RuleIndex < this.data.Count)
     {
         Rule rule = this.data[id.RuleIndex];
         if (rule.Id.Equals(id))
         {
             return(id.RuleIndex);
         }
     }
     foreach (Rule rule2 in this)
     {
         if (rule2.Id.Equals(id))
         {
             return(rule2.Id.RuleIndex);
         }
     }
     return(-1);
 }
Пример #2
0
 public static RuleId Deserialize(string base64Id, int ruleIndex)
 {
     if (base64Id == null)
     {
         throw new ArgumentNullException(base64Id);
     }
     byte[] byteArrayId = StoreId.Base64ToByteArray(base64Id);
     return(RuleId.Deserialize(byteArrayId, ruleIndex));
 }
Пример #3
0
        public static RuleId Deserialize(byte[] byteArrayId, int ruleIndex)
        {
            if (byteArrayId == null)
            {
                throw new ArgumentNullException("byteArrayId");
            }
            RuleId ruleId = new RuleId();

            ruleId.Parse(byteArrayId, ruleIndex);
            return(ruleId);
        }
Пример #4
0
        public Rule FindByRuleId(RuleId id)
        {
            this.CheckSaved();
            if (id == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Rules::Bind. {0} should not be null.", "id");
                throw new ArgumentNullException(ServerStrings.ExNullParameter("id", 1));
            }
            int indexByRuleId = this.GetIndexByRuleId(id);

            if (indexByRuleId != -1)
            {
                return(this[indexByRuleId]);
            }
            throw new ObjectNotFoundException(ServerStrings.ExItemNotFound);
        }
Пример #5
0
        public void Delete(RuleId id)
        {
            this.CheckSaved();
            ExTraceGlobals.StorageTracer.Information((long)this.GetHashCode(), "Rules::Delete.");
            if (id == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Rules::Delete. {0} should not be null.", "id");
                throw new ArgumentNullException(ServerStrings.ExNullParameter("id", 1));
            }
            int indexByRuleId = this.GetIndexByRuleId(id);

            if (indexByRuleId != -1)
            {
                this.data.RemoveAt(indexByRuleId);
                return;
            }
            throw new ObjectNotFoundException(ServerStrings.ExItemNotFound);
        }
Пример #6
0
        public override bool Equals(object id)
        {
            RuleId ruleId = id as RuleId;

            return(ruleId != null && this.storeRuleId == ruleId.storeRuleId);
        }