Ejemplo n.º 1
0
        public override object Copy(ICopyable zone)
        {

            if (zone != null)
            {
                var ret = zone as CCMoveBy;

                if (ret == null)
                {
                    return null;
                }

                base.Copy(zone);
                
                ret.InitWithDuration(m_fDuration, m_delta);
                
                return ret;
            }
            else
            {
                return new CCMoveBy(this);
            }


        }
Ejemplo n.º 2
0
        public override object Copy(ICopyable zone)
        {
            if (zone != null)
            {
                var ret = zone as CCRepeatForever;
                if (ret == null)
                {
                    return null;
                }
                base.Copy(zone);

                var param = m_pInnerAction.Copy() as CCActionInterval;
                if (param == null)
                {
                    return null;
                }
                ret.InitWithAction(param);

                return ret;
            }
            else
            {
                return new CCRepeatForever(this);
            }
        }
Ejemplo n.º 3
0
        public override object Copy(ICopyable zone)
        {
            ICopyable tmpZone = zone;
            CCSequence ret;

            if (tmpZone != null && tmpZone != null)
            {
                ret = tmpZone as CCSequence;
                if (ret == null)
                {
                    return null;
                }
				base.Copy(tmpZone);
				
				var param1 = m_pActions[0].Copy() as CCFiniteTimeAction;
				var param2 = m_pActions[1].Copy() as CCFiniteTimeAction;
				
				if (param1 == null || param2 == null)
				{
					return null;
				}
				
				ret.InitOneTwo(param1, param2);
				
				return ret;
            }
            else
            {
                return new CCSequence(this);
            }


        }
Ejemplo n.º 4
0
 /// <summary>This methods send some ICopyable data to the remote address.
 /// </summary>
 /// <param name="remote_addr">Remote Nodes are referenced by their P2P
 /// Address, typically of type AHAddress.</param>
 /// <param name="data">This is an ICopyable object which contains the data
 /// to send.</param>
 public void SendMessage(Address remote_addr, ICopyable data) {
   // This instantiates a multi-use method to sending to the remote node,
   // though we will only use it once.  It is VERY similar to UDP.
   AHExactSender sender = new AHExactSender(_app_node.Node, remote_addr);
   // This is the process of actually sending the data.
   sender.Send(new CopyList(HW, data));
 }
Ejemplo n.º 5
0
        public override object Copy(ICopyable zone)
        {
            if (zone != null)
            {
                var ret = zone as CCSpawn;
                if (ret == null)
                {
                    return null;
                }
                base.Copy(zone);

                var param1 = m_pOne.Copy() as CCFiniteTimeAction;
                var param2 = m_pTwo.Copy() as CCFiniteTimeAction;
                if (param1 == null || param2 == null)
                {
                    return null;
                }

                ret.InitOneTwo(param1, param2);

                return ret;
            }
            else
            {
                return new CCSpawn(this);
            }
        }
Ejemplo n.º 6
0
        public override object Copy(ICopyable zone)
        {

            if (zone != null)
            {
                var ret = zone as CCRepeat;
                if (ret == null)
                {
                    return null;
                }
                base.Copy(zone);
                
                var param = m_pInnerAction.Copy() as CCFiniteTimeAction;
                if (param == null)
                {
                    return null;
                }
                ret.InitWithAction(param, m_uTimes);
                
                return ret;
            }
            else
            {
                return new CCRepeat(this);
            }

        }
Ejemplo n.º 7
0
 public override void CopyFrom(ICopyable obj)
 {
     base.CopyFrom(obj);
     if (obj is IGeographicLocation)
     {
         IGeographicLocation g = (IGeographicLocation)obj;
         Latitude = g.Latitude;
         Longitude = g.Longitude;
     }            
 }
Ejemplo n.º 8
0
 public override void CopyFrom(ICopyable obj)
 {
     base.CopyFrom(obj);
     if (obj is IStatusCode)
     {
         IStatusCode sc = (IStatusCode)obj;
         Parts = new int[sc.Parts.Length];
         sc.Parts.CopyTo(Parts, 0);
     }
 }
Ejemplo n.º 9
0
 ///<summary>Pushes the data to the SecurityAssociation who will send it
 ///over the underlying edge.</summary>
 public override void Send(ICopyable data) {
   if(_closed == 1) {
     throw new EdgeClosedException("SecureEdge has been closed.");
   }
   try {
     SA.Send(data);
   } catch(Exception e) {
     throw new EdgeException(_closed == 1, "Unable to send on SE", e);
   }
 }
Ejemplo n.º 10
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            IOrganizer o = obj as IOrganizer;
            if (o != null)
            {
                Value = o.Value;
            }
        }
Ejemplo n.º 11
0
    public DataPacket(ICopyable packet) {
      _update_icpacket = false;
      _update_packet = false;

      _icpacket = packet;
      _packet = packet as MemBlock;
      if(_packet == null) {
        _update_packet = true;
      }
    }
Ejemplo n.º 12
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            IFreeBusyEntry fb = obj as IFreeBusyEntry;
            if (fb != null)
            {
                Status = fb.Status;
            }
        }
Ejemplo n.º 13
0
 public void Send(ICopyable Data) {
   byte[] data = new byte[Data.Length];
   Data.CopyTo(data, 0);
   MemBlock mdata = MemBlock.Reference(data);
   for(int i = 0; i < _remove_n_ptypes; i++) {
     MemBlock payload = mdata;
     PType.Parse(mdata, out payload);
     mdata = payload;
   }
   Receiver.HandleData(mdata, ReturnPath, State);
 }
Ejemplo n.º 14
0
        public override void CopyFrom(ICopyable c)
        {
            base.CopyFrom(c);

            ICalendarParameter p = c as ICalendarParameter;
            if (p != null)
            {
                if (p.Values != null)
                    _Values = new List<string>(p.Values);
            }
        }
Ejemplo n.º 15
0
 public virtual object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         ((CCAction) zone).m_nTag = m_nTag;
         return zone;
     }
     else
     {
         return new CCAction(this);
     }
 }
Ejemplo n.º 16
0
 public override object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         var ret = zone as CCScaleBy;
         base.Copy(zone); // Handles all data copying.
         return ret;
     }
     else
     {
         return new CCScaleBy(this);
     }
 }
Ejemplo n.º 17
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            IPeriod p = obj as IPeriod;
            if (p != null)
            {
                StartTime = p.StartTime;
                EndTime = p.EndTime;
                Duration = p.Duration;
                MatchesDateOnly = p.MatchesDateOnly;
            }
        }
Ejemplo n.º 18
0
 public override object Copy(ICopyable pZone)
 {
     if (pZone != null)
     {
         //in case of being called at sub class
         var pCopy = (CCFadeOut) (pZone);
         base.Copy(pZone);
         return pCopy;
     }
     else
     {
         return new CCFadeOut(this);
     }
 }
Ejemplo n.º 19
0
 public override object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         var ret = (CCFollow) zone;
         base.Copy(zone);
         ret.m_nTag = m_nTag;
         return ret;
     }
     else
     {
         return new CCFollow(this);
     }
 }
Ejemplo n.º 20
0
 public override object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         var ret = zone as CCReverseTime;
         base.Copy(zone);
         m_pOther = (CCFiniteTimeAction)ret.m_pOther; // .Copy() was in here before
         return ret;
     }
     else
     {
         return new CCReverseTime(this);
     }
 }
Ejemplo n.º 21
0
        public override void CopyFrom(ICopyable c)
        {
            base.CopyFrom(c);

            ICalendarParameter p = c as ICalendarParameter;
            if (p != null)
            {
                if (p.Values != null)
                {
                    Values = new string[p.Values.Length];
                    Array.Copy(p.Values, Values, p.Values.Length);
                }
            }
        }
Ejemplo n.º 22
0
 public override object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         var ret = zone as CCOrbitCamera;
         base.Copy(zone);
         Init(ret.m_fRadius, ret.m_fDeltaRadius, ret.m_fAngleZ, ret.m_fDeltaAngleZ, ret.m_fAngleX, ret.m_fDeltaAngleX);
         return ret;
     }
     else
     {
         return new CCOrbitCamera(this);
     }
 }
Ejemplo n.º 23
0
 public AHHeader(short hops, short ttl, Address source, Address dest, ushort options) {
   //Make the header part:
   byte[] header = new byte[ AHPacket.HeaderLength ];
   int offset = 0;
   //Write hops:
   NumberSerializer.WriteShort(hops, header, offset);
   offset += 2;
   NumberSerializer.WriteShort(ttl, header, offset);
   offset += 2;
   offset += source.CopyTo(header, offset);
   offset += dest.CopyTo(header, offset);
   NumberSerializer.WriteShort((short)options, header, offset);
   offset += 2;
   _data = MemBlock.Reference(header, 0, offset);
 }
Ejemplo n.º 24
0
 public override object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         var ret = zone as CCScaleTo;
         base.Copy(zone);
         m_fEndScaleX = ret.m_fEndScaleX;
         m_fEndScaleY = ret.m_fEndScaleY;
         return ret;
     }
     else
     {
         return new CCScaleTo(this);
     }
 }
Ejemplo n.º 25
0
 public override object Copy(ICopyable zone)
 {
     if (zone != null)
     {
         //in case of being called at sub class
         var pRet = (CCCallFuncND) (zone);
         base.Copy(zone);
         pRet.InitWithTarget(m_pCallFuncND, m_pData);
         return pRet;
     }
     else
     {
         return new CCCallFuncND(this);
     }
 }
Ejemplo n.º 26
0
Archivo: Udp.cs Proyecto: bakriy/brunet
 /**
 <summary>Creates a Udp Packet given the source port, destination port
 and the payload.</summary>
 <param name="SourcePort">The packets originating port</param>
 <param name="DestinationPort">The packets destination port</param>
 <param name="Payload">The data for the packet.</param>
 */
 public UdpPacket(int SourcePort, int DestinationPort, ICopyable Payload) {
   byte[] header = new byte[8];
   header[0] = (byte) ((SourcePort >> 8) & 0xFF);
   header[1] = (byte) (SourcePort & 0xFF);
   header[2] = (byte) ((DestinationPort >> 8) & 0xFF);
   header[3] = (byte) (DestinationPort & 0xFF);
   int length = Payload.Length + 8;
   header[4] = (byte) ((length >> 8) & 0xFF);
   header[5] = (byte) (length & 0xFF);
   // Checksums are disabled!
   header[6] = (byte) 0;
   header[7] = (byte) 0;
   _icpacket = new CopyList(MemBlock.Reference(header), Payload);
   _icpayload = Payload;
 }
Ejemplo n.º 27
0
        public override object Copy(ICopyable pZone)
        {
            if (pZone != null)
            {
                //in case of being called at sub class
                var pCopy = pZone as CCEaseBounceIn;
                pCopy.InitWithAction((CCActionInterval) (m_pOther.Copy()));

                return pCopy;
            }
            else
            {
                return new CCEaseBounceIn(this);
            }
        }
Ejemplo n.º 28
0
        public override object Copy(ICopyable zone)
        {
            if (zone != null)
            {
                var ret = (CCMoveTo) zone;
                base.Copy(zone);
                ret.InitWithDuration(m_fDuration, m_endPosition);

                return ret;
            }
            else
            {
                return new CCMoveTo(this);
            }
        }
Ejemplo n.º 29
0
 public override object Copy(ICopyable pZone)
 {
     if (pZone != null) //in case of being called at sub class
     {
         var pRet = (CCTargetedAction) (pZone);
         base.Copy(pZone);
         // win32 : use the m_pOther's copy object.
         pRet.InitWithTarget(m_pTarget, (CCFiniteTimeAction) m_pAction.Copy());
         return pRet;
     }
     else
     {
         return new CCTargetedAction(this);
     }
 }
Ejemplo n.º 30
0
        /// <summary>Used to send data over the tunnel via forwarding senders
        /// using a randomly selected peer from our overlap list.</summary>
        public void HandleEdgeSend(Edge from, ICopyable data)
        {
            RelayEdge  te        = from as RelayEdge;
            Connection forwarder = te.NextForwarder;

            if (te.RemoteID == -1)
            {
                Address target = (te.RemoteTA as RelayTransportAddress).Target;
                ISender sender = new ForwardingSender(_node, forwarder.Address, target);
                sender.Send(new CopyList(PType.Protocol.Relaying, te.MId, data));
            }
            else
            {
                try {
                    forwarder.State.Edge.Send(new CopyList(te.Header, te.MId, data));
                } catch {
                    // We could be sending aon a closed edge... we could deal with this
                    // better, but let's just let the system take its natural course.
                }
            }
        }
Ejemplo n.º 31
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);
            if (obj is IAttachment)
            {
                IAttachment a = (IAttachment)obj;
                ValueEncoding = a.ValueEncoding;

                if (a.Data != null)
                {
                    Data = new byte[a.Data.Length];
                    a.Data.CopyTo(Data, 0);
                }
                else
                {
                    Data = null;
                }

                Uri = a.Uri;
            }
        }
Ejemplo n.º 32
0
        /**
         * <summary>Sends the data over the unicast socket.</summary>
         * <param name="data">The data to send.</summary>
         */
        public virtual void Send(ICopyable data)
        {
            // Silly users can trigger a handful of exceptions here...
            try {
                data = new CopyList(IPHandler.MagicCookie, data);
                byte[] buffer = new byte[data.Length];
                int    length = data.CopyTo(buffer, 0);

                _s.SendTo(buffer, 0, length, 0, EndPoint);
            }
            catch (System.Net.Sockets.SocketException sx) {
                throw new SendException(true, "SocketException", sx);
            }
            catch (ObjectDisposedException odx) {
                throw new SendException(false, "Socket appears to be disposed", odx);
            }
            catch (Exception e) {
                ProtocolLog.WriteIf(ProtocolLog.Exceptions, "ERROR: " + e);
                throw new SendException(true, "Socket appears to be disposed", e);
            }
        }
Ejemplo n.º 33
0
    /*
     * public ICopyable GetEnemy(EnemyType enemyType)
     * {
     *  switch (enemyType)
     *  {
     *      case EnemyType.Drone:
     *          return Instantiate(Resources.Load("Drone", typeof(Enemy)) as Enemy);;
     *      case EnemyType.Sniper:
     *          return Instantiate(Resources.Load("Sniper", typeof(Enemy)) as Enemy);
     *  }
     *  return null;
     * }
     */
    public ICopyable GetEnemy(Enemy enemy, bool usePrefab = true)
    {
        copyable = null;
        if (usePrefab)
        {
            if (enemy.GetType() == typeof(Drone))
            {
                copyable = enemy.Copy("Drone");
            }
            else if (enemy.GetType() == typeof(Sniper))
            {
                copyable = enemy.Copy("Sniper");
            }
        }
        else
        {
            copyable = enemy.Copy();
        }

        return(copyable as Enemy);
    }
Ejemplo n.º 34
0
 public void Send(ICopyable data)
 {
     if (0 == Interlocked.Exchange(ref have_sent, 1))
     {
         //Make the header:
         byte[] header = new byte[5];
         header[0] = (byte)ReqrepType.Reply;
         NumberSerializer.WriteInt(RequestID, header, 1);
         MemBlock mb_header = MemBlock.Reference(header);
         Reply = new CopyList(_prefix, mb_header, data);
         Resend();
     }
     else
     {
         /*
          * Something goofy is going on here.  Multiple
          * sends for one request.  we are ignoring it for
          * now
          */
     }
 }
Ejemplo n.º 35
0
 /**
 <summary>Sends the data over the multicast socket.</summary>
 <param name="data">The data to send.</summary>
 */
 public override void Send(ICopyable data) {
   IPAddress[] ips = LocalIPAddresses;
   if(ips == null) {
     ips = IPHandler.GetLocalIPAddresses();
   }
   // Silly users can trigger a handful of exceptions here...
   try {
     data = new CopyList(IPHandler.MagicCookie, data);
     byte[] buffer = new byte[data.Length];
     int length = data.CopyTo(buffer, 0);
     // I REALLY HATE THIS but we can't be setting this option in more than one thread!
     lock(_s) {
       foreach(IPAddress ip in ips) {
         /*
          * This can throw an exception on an invalid address, we need to skip it and move on!
          * Never showed to be an issue in Linux, but Windows does some weird things.
          */
         try {
           _s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface,
                             IPHandler.IPAddressToInt(ip));
         }
         catch {
           continue;
         }
         _s.SendTo(buffer, 0, length, 0, EndPoint);
       }
     }
   }
   catch(System.Net.Sockets.SocketException sx) {
     throw new SendException(true, "SocketException", sx);
   }
   // Can't pass the fact that the IPHandler is not running :-/
   catch (ObjectDisposedException odx) {
     throw new SendException(false, "Socket appears to be disposed", odx);
   }
   catch (Exception e) {
     ProtocolLog.WriteIf(ProtocolLog.Exceptions, "ERROR: " + e);
     throw new SendException(true, "Socket appears to be disposed", e);
   }
 }
Ejemplo n.º 36
0
        public static bool Draw(ILoadable loadable, IUndoable undoable, ICopyable copyable, ICompilable compilable)
        {
            try
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("File", EditorStyles.toolbarButton, GUILayout.Width(35)))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("New: Ctrl+Alt+N "), false, OnNew, loadable);
                    menu.AddItem(new GUIContent("Load: Ctrl+Alt+L"), false, OnLoad, loadable);
                    menu.AddItem(new GUIContent("Save: Ctrl+Alt+S"), false, OnSave, loadable);
                    menu.AddItem(new GUIContent("Export as constellation file"), false, OnExportAsCL, loadable);
                    menu.ShowAsContext();
                    return(true);
                }

                if (GUILayout.Button("Edit", EditorStyles.toolbarButton, GUILayout.Width(35)))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Undo: Ctrl+Alt+Z"), false, OnUndo, undoable);
                    menu.AddItem(new GUIContent("Redo: Ctrl+Alt+Y"), false, OnRedo, undoable);
                    menu.AddItem(new GUIContent("Copy: Ctrl+Alt+C"), false, Copy, copyable);
                    menu.AddItem(new GUIContent("Past: Ctrl+Alt+V"), false, Paste, copyable);
                    menu.ShowAsContext();
                    return(true);
                }

                if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, GUILayout.Width(70)))
                {
                    compilable.ParseScript();
                    return(true);
                }

                GUILayout.Label("", EditorStyles.toolbarButton);
                EditorGUILayout.EndHorizontal();
            }catch
            {
            }
            return(false);
        }
Ejemplo n.º 37
0
        ///<summary>All outgoing data filters through here.</summary>
        public void Send(ICopyable data)
        {
            if (!_active)
            {
                if (_closed == 1)
                {
                    throw new SendException(false, "SA closed, unable to send!");
                }
                UpdateSH(null, null);
                return;
            }

            // prepare the packet
            SecurityDataMessage sdm = new SecurityDataMessage();

            sdm.SPI  = _spi;
            sdm.Data = data as MemBlock;
            if (sdm.Data == null)
            {
                byte[] b = new byte[data.Length];
                data.CopyTo(b, 0);
                sdm.Data = MemBlock.Reference(b);
            }

            // Encrypt it!
            lock (_sync) {
                _current_sh.SignAndEncrypt(sdm);
            }

            // Prepare for sending and send over the underlying ISender!
            data = new CopyList(SecurityOverlord.Security, SecurityOverlord.SecureData, sdm.ICPacket);
            try {
                _sender.Send(data);
                _running = true;
            } catch (Exception e) {
                Close("Failed on sending");
                throw new SendException(false, "Failed on sending closing...", e);
            }
        }
Ejemplo n.º 38
0
        public override object Copy(ICopyable zone)
        {
            if (zone != null)
            {
                var ret = zone as CCMoveBy;

                if (ret == null)
                {
                    return(null);
                }

                base.Copy(zone);

                ret.InitWithDuration(m_fDuration, m_delta);

                return(ret);
            }
            else
            {
                return(new CCMoveBy(this));
            }
        }
Ejemplo n.º 39
0
        public virtual void Send(ICopyable data)
        {
            if (_rand.NextDouble() < _drop_rate)
            {
                return;
            }

            MemBlock mdata = data as MemBlock;

            if (mdata == null)
            {
                mdata = MemBlock.Copy(data);
            }

            for (int i = 0; i < _remove_n_ptypes; i++)
            {
                MemBlock payload = mdata;
                PType.Parse(mdata, out payload);
                mdata = payload;
            }
            Receiver.HandleData(mdata, ReturnPath, State);
        }
Ejemplo n.º 40
0
        /**
         * <summary>Takes in the IP Header fields and a payload to create an IP
         * Packet.  Unlisted fields are generated by this constructor automatically.
         * </summary>
         * <param name="Protocol">The type of payload</param>
         * <param name="SourceIP">The packets originating ip address</param>
         * <param name="DestinationIP">The destination for the packet</param>
         * <param name="hdr">The original header of the IPPacket</param>
         * <param name="Payload">The data stored in the IP Packet</param>
         */
        public IPPacket(Protocols Protocol, MemBlock SourceIP,
                        MemBlock DestinationIP, MemBlock hdr, ICopyable Payload)
        {
            byte[] header = new byte[20];
            // Version | IHL
            header[0] = hdr[0];
            // Just a routine header!
            header[1] = hdr[1];
            int length = header.Length + Payload.Length;

            header[2] = (byte)((length >> 8) & 0xFF);
            header[3] = (byte)(length & 0xFF);
            // Fragment crap
            header[4] = hdr[4];
            header[5] = hdr[5];
            header[6] = hdr[6];
            header[7] = hdr[7];
            // Ttl
            header[8] = hdr[8];
            header[9] = hdr[9];
            for (int i = 0; i < 4; i++)
            {
                header[12 + i] = SourceIP[i];
                header[16 + i] = DestinationIP[i];
            }
            int checksum = GenerateChecksum(MemBlock.Reference(header));

            header[10] = (byte)((checksum >> 8) & 0xFF);
            header[11] = (byte)(checksum & 0xFF);

            MemBlock Header = MemBlock.Reference(header);

            _icpacket = new CopyList(Header, Payload);

            this.Protocol      = Protocol;
            this.SourceIP      = SourceIP;
            this.DestinationIP = DestinationIP;
            _icpayload         = Payload;
        }
Ejemplo n.º 41
0
        public override void CopyFrom(ICopyable c)
        {
            var obj = c as ICalendarObject;

            if (obj == null)
            {
                return;
            }

            // Copy the name and basic information
            Name   = obj.Name;
            Parent = obj.Parent;
            Line   = obj.Line;
            Column = obj.Column;

            // Add each child
            Children.Clear();
            foreach (var child in obj.Children)
            {
                this.AddChild(child);
            }
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Makea full copy of this object and does not make any reference copies.
        /// </summary>
        /// <param name="zone"></param>
        /// <returns></returns>
        public override object Copy(ICopyable zone)
        {
            ICopyable  tmpZone = zone;
            CCParallel ret;

            if (tmpZone != null && tmpZone != null)
            {
                ret = tmpZone as CCParallel;
                base.Copy(tmpZone);

                CCFiniteTimeAction[] cp = new CCFiniteTimeAction[m_pActions.Length];
                for (int i = 0; i < m_pActions.Length; i++)
                {
                    cp[i] = m_pActions[i].Copy() as CCFiniteTimeAction;
                }
                ret.m_pActions = cp;
                return(ret);
            }
            else
            {
                return(new CCParallel(this));
            }
        }
Ejemplo n.º 43
0
        public void HandleEdgeSend(Edge from, ICopyable p)
        {
            TcpEdge sender = (TcpEdge)from;

            try {
                bool flushed = true;
                lock ( sender ) {
                    //Try to fill up the buffer:
                    sender.WriteToBuffer(p);
                    //Okay, we loaded the whole packet into the TcpEdge's buffer
                    //now it is time to try to flush the buffer:
                    flushed = sender.Flush();
                }
                if (!flushed)
                {
                    /*
                     * We should remember to try again when the socket is
                     * writable
                     */
                    ActionQueue.Enqueue(new SendWaitAction(sender.Socket));
                }
            }
            catch (EdgeException ex) {
                if (false == ex.IsTransient)
                {
                    //Go ahead and forget about this socket.
                    RequestClose(from);
                    ActionQueue.Enqueue(new CloseAction(sender, null));
                }
                //Rethrow the exception
                throw;
            }
            catch (Exception x) {
                //Assume any other error is transient:
                throw new EdgeException(true, String.Format("Could not send on: {0}", from), x);
            }
        }
Ejemplo n.º 44
0
        /// <summary>
        ///     Copies all relevant fields/properties from
        ///     the target object to the current one.
        /// </summary>
        /// <param name="obj"></param>
        public override sealed void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            var p = obj as ICalendarProperty;

            if (p != null)
            {
                // Copy/clone the object if possible (deep copy)
                var copyable = p.Values as ICopyable;

                if (copyable != null)
                {
                    SetValue(copyable.Copy <object>( ));
                }
                else
                {
                    var cloneable = p.Values as ICloneable;

                    if (cloneable != null)
                    {
                        SetValue(cloneable.Clone( ));
                    }
                    else
                    {
                        SetValue(p.Values);
                    }
                }

                // Copy parameters
                foreach (ICalendarParameter parm in p.Parameters)
                {
                    AddParameter(parm.Copy <ICalendarParameter>( ));
                }
            }
        }
Ejemplo n.º 45
0
        /// <summary>
        ///     Copies values from the target object to the
        ///     current object.
        /// </summary>
        /// <param name="obj"></param>
        public override sealed void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            var attachment = obj as IAttachment;

            if (attachment != null)
            {
                IAttachment a = attachment;
                ValueEncoding = a.ValueEncoding;

                if (a.Data != null)
                {
                    Data = new byte[a.Data.Length];
                    a.Data.CopyTo(Data, 0);
                }
                else
                {
                    Data = null;
                }

                Uri = a.Uri;
            }
        }
Ejemplo n.º 46
0
    void Awake()
    {
        movingObject = false;
        baseMesh     = gameObject.GetComponent <MeshFilter>().mesh;
        stimulus     = GetComponent <Stimulus>();

        gameObjects = UnityEngine.Object.FindObjectsOfType <GameObject>();

        foreach (GameObject obj in gameObjects)
        {
            ICopyable test_ICopyable = obj.GetComponent <ICopyable>();
            if (test_ICopyable != null)
            {
                Copyables.Add(test_ICopyable);
            }

            Humanoid test_h = obj.GetComponent <Humanoid>();
            if (test_h != null)
            {
                humanoids.Add(test_h);
            }
        }
        StartCoroutine("UpdateForm");
    }
Ejemplo n.º 47
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            ICalendarProperty p = obj as ICalendarProperty;

            if (p != null)
            {
                if (p.Value is ICopyable)
                {
                    Value = ((ICopyable)p.Value).Copy <object>();
                }
                else
                {
                    Value = p.Value;
                }

                // Copy parameters
                foreach (ICalendarParameter parm in p.Parameters)
                {
                    AddChild(parm.Copy <ICalendarParameter>());
                }
            }
        }
Ejemplo n.º 48
0
 public Body SpawnNewBody()
 {
     mCopy = newBod.Copy();
     return((Body)mCopy);
 }
Ejemplo n.º 49
0
        /// <summary>Look up a hostname given a Dns request in the form of IPPacket
        /// </summary>
        /// <param name="in_ip">An IPPacket containing the Dns request</param>
        /// <returns>An IPPacket containing the results</returns>
        public virtual IPPacket LookUp(IPPacket in_ip)
        {
            UdpPacket in_udp        = new UdpPacket(in_ip.Payload);
            DnsPacket in_dns        = new DnsPacket(in_udp.Payload);
            ICopyable out_dns       = null;
            string    qname         = string.Empty;
            bool      invalid_qtype = false;

            try {
                string qname_response = String.Empty;
                qname = in_dns.Questions[0].QName;
                DnsPacket.Types type = in_dns.Questions[0].QType;

                if (type == DnsPacket.Types.A || type == DnsPacket.Types.AAAA)
                {
                    qname_response = AddressLookUp(qname);
                }
                else if (type == DnsPacket.Types.Ptr)
                {
                    qname_response = NameLookUp(qname);
                }
                else
                {
                    invalid_qtype = true;
                }

                if (qname_response == null)
                {
                    throw new Exception("Unable to resolve");
                }

                Response response = new Response(qname, in_dns.Questions[0].QType,
                                                 in_dns.Questions[0].QClass, 1800, qname_response);
                //Host resolver will not accept if recursive is not available
                //when it is desired
                DnsPacket res_packet = new DnsPacket(in_dns.ID, false,
                                                     in_dns.Opcode, true, in_dns.RD, in_dns.RD,
                                                     in_dns.Questions, new Response[] { response }, null, null);

                out_dns = res_packet.ICPacket;
            } catch (Exception e) {
                bool failed_resolve = false;
                // The above resolver failed, let's see if another resolver works
                if (_forward_queries)
                {
                    try {
                        out_dns = Resolve(_name_server, (byte[])in_dns.Packet);
                    } catch (Exception ex) {
                        e = ex;
                        failed_resolve = true;
                    }
                }

                if (!_forward_queries || failed_resolve)
                {
                    ProtocolLog.WriteIf(IpopLog.Dns, "Failed to resolve: " + qname + "\n\t" + e.Message);
                    out_dns = DnsPacket.BuildFailedReplyPacket(in_dns, !invalid_qtype);
                }
            }

            UdpPacket out_udp = new UdpPacket(in_udp.DestinationPort,
                                              in_udp.SourcePort, out_dns);

            return(new IPPacket(IPPacket.Protocols.Udp, in_ip.DestinationIP,
                                in_ip.SourceIP,
                                out_udp.ICPacket));
        }
Ejemplo n.º 50
0
 //ToDo: See if this can be deleted
 public override void CopyFrom(ICopyable obj)
 {
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Copies values from the target object to the
 /// current object.
 /// </summary>
 public virtual void CopyFrom(ICopyable c)
 {
 }
        public bool Update <TDbContext, TEntity>(BaseDataAccessService <TDbContext, TEntity> dataService, int entityId, ICopyable <TEntity> copyImpl, string popUpText, bool popUpConfirm)
            where TDbContext : DbContext
            where TEntity : class
        {
            var vm = ServiceLocator.Current.GetInstance <IViewModelGetSelectedView>().GetSelectedView();

            if (popUpConfirm)
            {
                string hintText = TranslationService.Translate("View_Messagebox_ConfirmToUpdate") + ": \n" + popUpText;

                if (ServiceLocator.Current.GetInstance <IViewModelConfirmWindow>().ConfirmWindow(vm, hintText) == false)
                {
                    return(false);
                }
            }

            var rc = false;

            var tuple = dataService.LoadSingleTuple(entityId);

            if (tuple == null)
            {
                string hintText = popUpText + "\n" + TranslationService.Translate("View_Messagebox_DeleteAlready");
            }
            else
            {
                copyImpl.CopyTo(tuple);

                var result = dataService.Modify(tuple);

                if (result.ResultCode != ResultCodeOption.Ok)
                {
                    string hintText =
                        TranslationService.Translate("View_Messagebox_CannotUpdate") + ": \n" +
                        popUpText + "\n" +
                        TranslationService.Translate("View_Messagebox_Reason") + ": " + result.Message;

                    ServiceLocator.Current.GetInstance <IViewModelErrorWindow>().ErrorWindow(vm, hintText);
                    rc = false;
                }
                else
                {
                    ServiceLocator.Current.GetInstance <IViewModelHintWindow>().HintWindow(
                        vm,
                        TranslationService.Translate("View_Messagebox_Success") + "!");
                    rc = true;
                }
            }

            return(rc);
        }
Ejemplo n.º 53
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);
            if (obj is IRecurrencePattern)
            {
                IRecurrencePattern r = (IRecurrencePattern)obj;

                _Frequency = r.Frequency;
                _Until     = r.Until;
                _Count     = r.Count;
                _Interval  = r.Interval;

                if (r.BySecond != null)
                {
                    _BySecond = new List <int>(r.BySecond);
                }
                else
                {
                    _BySecond = null;
                }

                if (r.ByMinute != null)
                {
                    _ByMinute = new List <int>(r.ByMinute);
                }
                else
                {
                    _ByMinute = null;
                }

                if (r.ByHour != null)
                {
                    _ByHour = new List <int>(r.ByHour);
                }
                else
                {
                    _ByHour = null;
                }

                if (r.ByDay != null)
                {
                    _ByDay = new List <IWeekDay>(r.ByDay);
                }
                else
                {
                    _ByDay = null;
                }

                if (r.ByMonthDay != null)
                {
                    _ByMonthDay = new List <int>(r.ByMonthDay);
                }
                else
                {
                    _ByMonthDay = null;
                }

                if (r.ByYearDay != null)
                {
                    _ByYearDay = new List <int>(r.ByYearDay);
                }
                else
                {
                    _ByYearDay = null;
                }

                if (r.ByWeekNo != null)
                {
                    _ByWeekNo = new List <int>(r.ByWeekNo);
                }
                else
                {
                    _ByWeekNo = null;
                }

                if (r.ByMonth != null)
                {
                    _ByMonth = new List <int>(r.ByMonth);
                }
                else
                {
                    _ByMonth = null;
                }

                if (r.BySetPosition != null)
                {
                    _BySetPosition = new List <int>(r.BySetPosition);
                }
                else
                {
                    _BySetPosition = null;
                }

                _FirstDayOfWeek  = r.FirstDayOfWeek;
                _RestrictionType = r.RestrictionType;
                _EvaluationMode  = r.EvaluationMode;
            }
        }
Ejemplo n.º 54
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public DetailDesignator(Ownership <IdeaDefinition, Idea> Owner, string Name, string TechName, string Summary = "", ICopyable Initializer = null, ImageSource Pictogram = null)
            : base(Name, TechName, Summary, Pictogram)
        {
            this.Owner = Owner;

            this.Initializer = Initializer;
        }
Ejemplo n.º 55
0
 public Enemy SpawnEnemy(Enemy prototype)
 {
     copy = prototype.Copy();
     return((Enemy)copy);
 }
Ejemplo n.º 56
0
 ///<summary>Sends the data over the underlying edge.</summary>
 public override void Send(ICopyable p)
 {
     _edge.Send(p);
 }
Ejemplo n.º 57
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public LinkDetailDesignator(Ownership <IdeaDefinition, Idea> Owner,
                                    string Name, string TechName, string Summary = "", ICopyable Initializer = null, ImageSource Pictogram = null)
            : base(Owner, Name, TechName, Summary, Initializer, Pictogram)
        {
            this.DeclaringLinkType = (Initializer is MModelPropertyDefinitor
                                      ? InternalLinkType.InternalTypeAny
                                      : LinkDataType.GenericLink);

            this.LinkLook = new LinkAppearance();
        }
Ejemplo n.º 58
0
 public override void Send(ICopyable data)
 {
     _queue.Enqueue(data);
 }
Ejemplo n.º 59
0
 /*
  * Send a packet by forwarding it first.
  */
 public void Send(ICopyable d)
 {
     _sender.Send(new CopyList(_header, d));
 }
Ejemplo n.º 60
-1
 public override void CopyFrom(ICopyable obj)
 {
     base.CopyFrom(obj);
     if (obj is IRequestStatus)
     {
         IRequestStatus rs = (IRequestStatus)obj;                
         if (rs.StatusCode != null)
             StatusCode = rs.StatusCode.Copy<IStatusCode>();
         Description = rs.Description;
         rs.ExtraData = rs.ExtraData;
     }
 }