コード例 #1
0
ファイル: Slot.cs プロジェクト: samuto/designscript
        /// <summary>
        /// Create a new slot
        /// </summary>
        /// <param name="gc">Owning graph controller</param>
        /// <param name="type">Input/Output slot</param>
        /// <param name="firstOwner">Node where there slot resides</param>
        internal Slot(IGraphController gc, SlotType type, IVisualNode firstOwner)
        {
            if (gc == null || firstOwner == null)
                throw new ArgumentNullException();

            this.graphController = gc as GraphController;
            Validity.Assert(this.graphController != null);
            IdGenerator idGenerator = this.graphController.GetIdGenerator();

            this.slotType = type;
            this.version = Slot.Version.Current;
            this.slotId = idGenerator.GetNextId(ComponentType.Slot);
            this.slotState = SlotStates.Visible;
            this.owners.Add(firstOwner.NodeId);
        }
コード例 #2
0
ファイル: Slot.cs プロジェクト: seasailor/designscript
        /// <summary>
        /// Create a new slot
        /// </summary>
        /// <param name="gc">Owning graph controller</param>
        /// <param name="type">Input/Output slot</param>
        /// <param name="firstOwner">Node where there slot resides</param>
        internal Slot(IGraphController gc, SlotType type, IVisualNode firstOwner)
        {
            if (gc == null || firstOwner == null)
            {
                throw new ArgumentNullException();
            }

            this.graphController = gc as GraphController;
            Validity.Assert(this.graphController != null);
            IdGenerator idGenerator = this.graphController.GetIdGenerator();

            this.slotType  = type;
            this.version   = Slot.Version.Current;
            this.slotId    = idGenerator.GetNextId(ComponentType.Slot);
            this.slotState = SlotStates.Visible;
            this.owners.Add(firstOwner.NodeId);
        }
コード例 #3
0
ファイル: Slot.cs プロジェクト: seasailor/designscript
        public bool Deserialize(IStorage storage)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            if (storage.ReadUnsignedInteger(FieldCode.SlotSignature) != Configurations.SlotSignature)
            {
                throw new InvalidOperationException("Invalid input data {9D939DA2}");
            }

            try
            {
                this.slotType  = (SlotType)storage.ReadInteger(FieldCode.SlotType);
                this.version   = (Slot.Version)storage.ReadInteger(FieldCode.SlotVersion);
                this.slotId    = storage.ReadUnsignedInteger(FieldCode.SlotId);
                this.slotState = (SlotStates)storage.ReadInteger(FieldCode.SlotState);

                int ownersCount = storage.ReadInteger(FieldCode.OwnersCount);
                this.owners.Clear();
                for (int i = 0; i < ownersCount; i++)
                {
                    owners.Add(storage.ReadUnsignedInteger(FieldCode.Owners));
                }

                int connectingSlotsCount = storage.ReadInteger(FieldCode.ConnectingSlotsCount);
                this.connectingSlots.Clear();
                for (int i = 0; i < connectingSlotsCount; i++)
                {
                    connectingSlots.Add(storage.ReadUnsignedInteger(FieldCode.ConnectingSlots));
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\n Slot deserialization failed.");
                return(false);
            }
        }
コード例 #4
0
ファイル: Slot.cs プロジェクト: samuto/designscript
        public bool Deserialize(IStorage storage)
        {
            if (storage == null)
                throw new ArgumentNullException("storage");

            if (storage.ReadUnsignedInteger(FieldCode.SlotSignature) != Configurations.SlotSignature)
                throw new InvalidOperationException("Invalid input data {9D939DA2}");

            try
            {
                this.slotType = (SlotType)storage.ReadInteger(FieldCode.SlotType);
                this.version = (Slot.Version)storage.ReadInteger(FieldCode.SlotVersion);
                this.slotId = storage.ReadUnsignedInteger(FieldCode.SlotId);
                this.slotState = (SlotStates)storage.ReadInteger(FieldCode.SlotState);

                int ownersCount = storage.ReadInteger(FieldCode.OwnersCount);
                this.owners.Clear();
                for (int i = 0; i < ownersCount; i++)
                    owners.Add(storage.ReadUnsignedInteger(FieldCode.Owners));

                int connectingSlotsCount = storage.ReadInteger(FieldCode.ConnectingSlotsCount);
                this.connectingSlots.Clear();
                for (int i = 0; i < connectingSlotsCount; i++)
                    connectingSlots.Add(storage.ReadUnsignedInteger(FieldCode.ConnectingSlots));

                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\n Slot deserialization failed.");
                return false;
            }
        }