Ejemplo n.º 1
0
 public static void SetHostVersion(IAtomCollection host)
 {
     host.SetHostVersion(ServantVersion);
       host.SetHostVersionVP(ServantVersionVP);
       host.SetHostVersionEXPrefix(ServantVersionEXPrefix);
       host.SetHostVersionEXNumber(ServantVersionEXNumber);
 }
Ejemplo n.º 2
0
 public static void SetBcstVersion(IAtomCollection bcst)
 {
     bcst.SetBcstVersion(ServantVersion);
       bcst.SetBcstVersionVP(ServantVersionVP);
       bcst.SetBcstVersionEXPrefix(ServantVersionEXPrefix);
       bcst.SetBcstVersionEXNumber(ServantVersionEXNumber);
 }
 public static Guid? GetIDFrom(IAtomCollection collection, ID4 name)
 {
   var atom = collection.FindByName(name);
   byte[] value = null;
   if (atom != null && atom.TryGetBytes(out value) && value.Length==16) {
     return ByteArrayToID(value);
   }
   else {
     return null;
   }
 }
 public static ushort? GetUShortFrom(IAtomCollection collection, ID4 name)
 {
   var atom = collection.FindByName(name);
   ushort value = 0;
   if (atom != null && atom.TryGetUInt16(out value)) {
     return value;
   }
   else {
     return null;
   }
 }
 public static byte? GetByteFrom(IAtomCollection collection, ID4 name)
 {
   var atom = collection.FindByName(name);
   byte value = 0;
   if (atom != null && atom.TryGetByte(out value)) {
     return value;
   }
   else {
     return null;
   }
 }
 public static int? GetIntFrom(IAtomCollection collection, ID4 name)
 {
   var atom = collection.FindByName(name);
   int value = 0;
   if (atom != null && atom.TryGetInt32(out value)) {
     return value;
   }
   else {
     return null;
   }
 }
        public static Guid?GetIDFrom(IAtomCollection collection, ID4 name)
        {
            var atom = collection.FindByName(name);

            byte[] value = null;
            if (atom != null && atom.TryGetBytes(out value) && value.Length == 16)
            {
                return(ByteArrayToID(value));
            }
            else
            {
                return(null);
            }
        }
        public static ushort?GetUShortFrom(IAtomCollection collection, ID4 name)
        {
            var    atom  = collection.FindByName(name);
            ushort value = 0;

            if (atom != null && atom.TryGetUInt16(out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
        public static byte?GetByteFrom(IAtomCollection collection, ID4 name)
        {
            var  atom  = collection.FindByName(name);
            byte value = 0;

            if (atom != null && atom.TryGetByte(out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
        public static IPEndPoint GetHostUphostEndPoint(this IAtomCollection collection)
        {
            var ip   = GetIPAddressFrom(collection, Atom.PCP_HOST_UPHOST_IP);
            var port = GetIntFrom(collection, Atom.PCP_HOST_UPHOST_PORT);

            if (ip != null && port != null)
            {
                return(new IPEndPoint(ip, port.Value));
            }
            else
            {
                return(null);
            }
        }
        public static int?GetIntFrom(IAtomCollection collection, ID4 name)
        {
            var atom  = collection.FindByName(name);
            int value = 0;

            if (atom != null && atom.TryGetInt32(out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
        public static string GetStringFrom(IAtomCollection collection, ID4 name)
        {
            string res  = null;
            var    atom = collection.FindByName(name);

            if (atom != null && atom.TryGetString(out res))
            {
                return(res);
            }
            else
            {
                return(null);
            }
        }
        public static IPAddress GetIPAddressFrom(IAtomCollection collection, ID4 name)
        {
            var       atom  = collection.FindByName(name);
            IPAddress value = null;

            if (atom != null && atom.TryGetIPAddress(out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
        public static ID4?GetID4From(IAtomCollection collection, ID4 name)
        {
            var atom = collection.FindByName(name);

            byte[] value = null;
            if (atom != null && atom.TryGetBytes(out value) && value.Length == 4)
            {
                return(new ID4(value));
            }
            else
            {
                return(null);
            }
        }
        XElement ConvertCollection(IAtomCollection collection)
        {
            if (collection == null)
            {
                return(null);
            }

            var result = new XElement(ApplicationNamespace + "collection",
                                      new XAttribute("href", collection.Uri),
                                      new XElement(CmisRestAtomPubNamespace + "collectionType", collection.CollectionType.ToCmisName()),
                                      new XElement(AtomPubNamespace + "title", new XAttribute("type", "text"), collection.Title));

            foreach (var accept in collection.Accept)
            {
                var element = new XElement(ApplicationNamespace + "accept", accept.ToCmisName());
                result.Add(element);
            }

            return(result);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 他のAtomCollectionの内容をこのインスタンスに上書きします。
 /// 同じ名前の要素は上書きされ、異なる名前の要素は追加または残されます
 /// </summary>
 /// <param name="other">上書きするコレクション</param>
 public void Update(IAtomCollection other)
 {
     foreach (var atom in other)
     {
         var updated = false;
         for (var i = 0; i < this.Count; i++)
         {
             if (atom.Name == this[i].Name)
             {
                 updated = true;
                 this[i] = atom;
                 break;
             }
         }
         if (!updated)
         {
             this.Add(atom);
         }
     }
 }
 public static void SetHostOldPos(this IAtomCollection collection, uint value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_OLDPOS, value));
 }
Ejemplo n.º 18
0
 /// <summary>
 /// チャンネル情報を保持するAtomCollectionから新しいチャンネル情報を初期化します
 /// </summary>
 /// <param name="chaninfo">チャンネル情報を保持するAtomCollection</param>
 public ChannelInfo(IAtomCollection chaninfo)
 {
   extra = new ReadOnlyAtomCollection(new AtomCollection(chaninfo));
 }
 public static IPAddress GetIPAddressFrom(IAtomCollection collection, ID4 name)
 {
     var atom = collection.FindByName(name);
       IPAddress value = null;
       if (atom != null && atom.TryGetIPv4Address(out value)) {
     return value;
       }
       else {
     return null;
       }
 }
 public static void SetHostUptime(this IAtomCollection collection, TimeSpan value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_UPTIME, (int)value.TotalSeconds));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// トラック情報を保持するAtomCollectionから新しいトラック情報を初期化します
 /// </summary>
 /// <param name="chantrack">トラック情報を保持するAtomCollection</param>
 public ChannelTrack(IAtomCollection chantrack)
 {
   extra = new ReadOnlyAtomCollection(new AtomCollection(chantrack));
 }
 public static void AddHostPort(this IAtomCollection collection, int value)
 {
     collection.Add(new Atom(Atom.PCP_HOST_PORT, (ushort)value));
 }
 public static void SetHostUphostIP(this IAtomCollection collection, IPAddress value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_UPHOST_IP, value));
 }
 public static IAtomCollection GetCollectionFrom(IAtomCollection collection, ID4 name)
 {
     var atom = collection.FindByName(name);
       if (atom != null && atom.HasChildren) {
     return atom.Children;
       }
       else {
     return null;
       }
 }
 public static void SetChanTrack(this IAtomCollection collection, IList <Atom> value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_CHAN_TRACK, value));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// ホスト情報を初期化します
 /// </summary>
 public Host(
   Guid sessionID,
   Guid broadcastID,
   IPEndPoint localEndPoint,
   IPEndPoint globalEndPoint,
   int relayCount,
   int directCount,
   bool isFirewalled,
   bool isTracker,
   bool isRelayFull,
   bool isDirectFull,
   bool isReceiving,
   bool isControlFull,
   IEnumerable<string> extensions,
   IAtomCollection extra)
 {
   this.SessionID      = sessionID;
   this.BroadcastID    = broadcastID;
   this.LocalEndPoint  = localEndPoint;
   this.GlobalEndPoint = globalEndPoint;
   this.RelayCount     = relayCount;
   this.DirectCount    = directCount;
   this.IsFirewalled   = isFirewalled;
   this.IsTracker      = isTracker;
   this.IsRelayFull    = isRelayFull;
   this.IsDirectFull   = isDirectFull;
   this.IsReceiving    = isReceiving;
   this.IsControlFull  = isControlFull;
   this.Extensions     = new List<string>(extensions).AsReadOnly();
   this.Extra          = (new AtomCollection(extra)).AsReadOnly();
   this.LastUpdated    = Environment.TickCount;
 }
Ejemplo n.º 27
0
 /// <summary>
 /// 他のAtomCollectionの内容をこのインスタンスに上書きします。
 /// 常にNotSupporetedExceptionを投げます。
 /// </summary>
 /// <param name="other">上書きするコレクション</param>
 public void Update(IAtomCollection other)
 {
     throw new NotSupportedException();
 }
 public static Atom GetAtomFrom(IAtomCollection collection, ID4 name)
 {
     return collection.FindByName(name);
 }
 public static void SetAtomTo(IAtomCollection collection, Atom value)
 {
     for (var i = 0; i < collection.Count; i++) {
     if (value.Name == collection[i].Name) {
       collection[i] = value;
       return;
     }
       }
       collection.Add(value);
 }
 public static string GetStringFrom(IAtomCollection collection, ID4 name)
 {
     string res = null;
       var atom = collection.FindByName(name);
       if (atom != null && atom.TryGetString(out res)) {
     return res;
       }
       else {
     return null;
       }
 }
 public static void SetHostNumListeners(this IAtomCollection collection, int value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_NUML, value));
 }
 public static void SetChanTrackCreator(this IAtomCollection collection, string value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_CHAN_TRACK_CREATOR, value));
 }
 public static void SetHostNumRelays(this IAtomCollection collection, int value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_NUMR, value));
 }
 public static void SetChanTrackURL(this IAtomCollection collection, string value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_CHAN_TRACK_URL, value));
 }
 public static void SetHostSessionID(this IAtomCollection collection, Guid value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_ID, IDToByteArray(value)));
 }
 public static void SetHost(this IAtomCollection collection, IList <Atom> value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST, value));
 }
 public static void SetHostUphostPort(this IAtomCollection collection, int value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_UPHOST_PORT, value));
 }
 public static void SetHostClapPP(this IAtomCollection collection, int value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_CLAP_PP, value));
 }
 public static void SetHostVersion(this IAtomCollection collection, int value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_VERSION, value));
 }
 public static void SetHostFlags1(this IAtomCollection collection, PCPHostFlags1 value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_HOST_FLAGS1, (byte)value));
 }
Ejemplo n.º 41
0
 public static void SetHeloVersion(IAtomCollection helo)
 {
     helo.SetHeloVersion(ServantVersion);
 }
 public static void AddHostIP(this IAtomCollection collection, IPAddress value)
 {
     collection.Add(new Atom(Atom.PCP_HOST_IP, value));
 }
 public static void SetChanPktPos(this IAtomCollection collection, uint value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_CHAN_PKT_POS, value));
 }
 public static ID4? GetID4From(IAtomCollection collection, ID4 name)
 {
     var atom = collection.FindByName(name);
       byte[] value = null;
       if (atom != null && atom.TryGetBytes(out value) && value.Length==4) {
     return new ID4(value);
       }
       else {
     return null;
       }
 }
Ejemplo n.º 45
0
 /// <summary>
 /// 名前と子のコレクションを指定してAtomを初期化します。
 /// </summary>
 /// <param name="name">4文字以下の名前</param>
 /// <param name="children">保持する子のコレクション</param>
 public Atom(ID4 name, IList <Atom> children)
 {
     Name          = name;
     this.children = new ReadOnlyAtomCollection(new AtomCollection(children));
 }
 public static void SetChanPktType(this IAtomCollection collection, ID4 value)
 {
     SetAtomTo(collection, new Atom(Atom.PCP_CHAN_PKT_TYPE, value.GetBytes()));
 }