public IUsage FromReader(ReloadMessage rm, BinaryReader reader, long usage_size) //REDIR_SERVICE_PROVIDER { codePoint = Usage_Code_Point.REDIR_SERVICE_PROVIDER; UInt16 namespacelength; string nameSpace; UInt16 level; UInt16 node; NodeId serviceProviderID; try { uint length = (UInt32)(System.Net.IPAddress.NetworkToHostOrder((int)reader.ReadInt32())); UInt16 serviceProviderID_len = (UInt16)(System.Net.IPAddress.NetworkToHostOrder(reader.ReadInt16())); serviceProviderID = new NodeId(reader.ReadBytes(serviceProviderID_len)); namespacelength = (UInt16)(System.Net.IPAddress.NetworkToHostOrder(reader.ReadInt16())); nameSpace = Encoding.ASCII.GetString(reader.ReadBytes(namespacelength)); //ASCII for wireshark dissector level = (UInt16)(System.Net.IPAddress.NetworkToHostOrder(reader.ReadInt16())); node = (UInt16)(System.Net.IPAddress.NetworkToHostOrder(reader.ReadInt16())); string resourceName = (nameSpace + "," + level + "," + node); RedirServiceProvider serviceProvider = new RedirServiceProvider(serviceProviderID, resourceName, nameSpace, level, node, myManager); return serviceProvider; } catch (Exception ex) { throw ex; } }
public IUsage Create(int? type, params object[] arguments) { if (arguments.Count() < 4) throw new ArgumentException("Not enough arguments! Need 0=key 1=nameSpace, 2=level, 3=node"); if (arguments[0] == null || arguments[1] == null || arguments[2] == null || arguments[3] == null) throw new ArgumentNullException("Not enough arguments! Any of the the arguments is null!"); RedirServiceProvider serviceProvider = new RedirServiceProvider(myManager.localNode.Id, (string)arguments[0], (string)arguments[1], UInt16.Parse((string)arguments[2]), UInt16.Parse((string)arguments[3]), myManager); return serviceProvider; }