public void CopyChangesFrom(IConfigurable source) { if (source == null) { throw new ArgumentNullException("source"); } IPListEntry iplistEntry = source as IPListEntry; if (iplistEntry == null) { throw new ArgumentException(DirectoryStrings.ExceptionCopyChangesForIncompatibleTypes(source.GetType(), base.GetType()), "source"); } if (iplistEntry.identity != null) { this.identity = new IPListEntryIdentity(iplistEntry.identity.Index); } if (iplistEntry.range != null) { this.range = new IPRange(new IPvxAddress(iplistEntry.range.LowerBound), new IPvxAddress(iplistEntry.range.UpperBound), iplistEntry.range.RangeFormat); } this.expirationTimeUtc = iplistEntry.expirationTimeUtc; this.isMachineGenerated = iplistEntry.IsMachineGenerated; this.listType = iplistEntry.ListType; this.isValid = iplistEntry.IsValid; this.comment = iplistEntry.Comment; }
internal static T NewIPListEntry <T>(IPFilterRange range) where T : IConfigurable, new() { IPListEntry iplistEntry = (IPListEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); IPRange.Format format = (IPRange.Format)(range.Flags & 15); IPListEntryType iplistEntryType = (IPListEntryType)(range.Flags >> 4 & 15); IPListEntry.AuthorType authorType = (IPListEntry.AuthorType)(range.Flags >> 8 & 15); iplistEntry.identity = new IPListEntryIdentity(range.Identity); ulong high; ulong low; range.GetLowerBound(out high, out low); IPvxAddress startAddress = new IPvxAddress(high, low); range.GetUpperBound(out high, out low); IPvxAddress endAddress = new IPvxAddress(high, low); iplistEntry.range = new IPRange(startAddress, endAddress, format); iplistEntry.expirationTimeUtc = range.ExpiresOn.ToUniversalTime(); iplistEntry.isMachineGenerated = (authorType == IPListEntry.AuthorType.Automatic); iplistEntry.listType = iplistEntryType; iplistEntry.comment = range.Comment; return((T)((object)iplistEntry)); }
public void Delete(IConfigurable instance) { IPListEntry entry = (IPListEntry)instance; RpcClientHelper.Invoke(delegate { this.connection.Remove(((IPListEntryIdentity)entry.Identity).Index, entry.ListType == IPListEntryType.Block); return(null); }); }
public void Save(IConfigurable instance) { IPListEntry entry = (IPListEntry)instance; int num = (int)RpcClientHelper.Invoke(() => this.connection.Add(entry.ListType == IPListEntryType.Block, entry.ToIPFilterRange())); if (num == -1) { throw new DataSourceOperationException(Strings.IPListEntryExists(entry.IPRange.ToString())); } entry.Identity = new IPListEntryIdentity(num); }
public IConfigurable Read <T>(ObjectId identity) where T : IConfigurable, new() { int index = ((IPListEntryIdentity)identity).Index; IPFilterRange[] items = this.GetItems(index, this.GetFilterMask <T>(), IPvxAddress.None, 1); if (items != null && items.Length > 0 && items[0].Identity == index) { return(IPListEntry.NewIPListEntry <T>(items[0])); } return(null); }
public IEnumerator <T> GetEnumerator() { IEnumerator <IPFilterRange[]> pages = this.GetPages(); while (pages.MoveNext()) { foreach (IPFilterRange range in pages.Current) { yield return(IPListEntry.NewIPListEntry <T>(range)); } } yield break; }
private int GetFilterMask <T>() where T : IConfigurable, new() { IPListEntry iplistEntry = (IPListEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); switch (iplistEntry.ListType) { case IPListEntryType.Allow: return(3856); case IPListEntryType.Block: return(3872); default: throw new ArgumentException("Invalid IPListEntryType. This should never happen."); } }