コード例 #1
0
        /// <summary>
        /// Interrupt Handler
        /// </summary>
        /// <param name="m"></param>
        /// <param name="length"></param>
        public void OnStateUpdate(DataReader m, uint length)
        {
            lock (syncObject)
            {
                EnableFlags enableflags = (EnableFlags)m.ReadByte();

                StrongPullup = ((enableflags & EnableFlags.SPUE) == EnableFlags.SPUE) ? true : false;
                oneWireState.oneWireLevel = (byte)((StrongPullup == true) ?
                                                   DSPortAdapter.LEVEL_POWER_DELIVERY : DSPortAdapter.LEVEL_NORMAL);
                DynamicSpeedChange        = ((enableflags & EnableFlags.SPCE) == EnableFlags.SPCE) ? true : false;
                BusCommSpeed              = m.ReadByte();
                ReqBusCommSpeed           = -1;
                oneWireState.oneWireSpeed = BusCommSpeed;
                StrongPullupDuration      = m.ReadByte();
                ProgPullupDuration        = m.ReadByte();
                PulldownSlewRateControl   = m.ReadByte();
                Write1LowTime             = m.ReadByte();
                DSOW0RecoveryTime         = m.ReadByte();
                var rsvd1 = m.ReadByte();

                StatusFlags statusflags = (StatusFlags)m.ReadByte();

                StrongPullup1             = ((statusflags & StatusFlags.SPUA) == StatusFlags.SPUA) ? true : false;
                ProgrammingVoltagePresent = ((statusflags & StatusFlags.PVP) == StatusFlags.PVP) ? true : false;
                oneWireState.canProgram   = ProgrammingVoltagePresent;
                PowerMode = ((statusflags & StatusFlags.PMOD) == StatusFlags.PMOD) ? true : false;
                Halt      = ((statusflags & StatusFlags.HALT) == StatusFlags.HALT) ? true : false;
                Idle      = ((statusflags & StatusFlags.IDLE) == StatusFlags.IDLE) ? true : false;
                Ep0Fifo   = ((statusflags & StatusFlags.EP0F) == StatusFlags.EP0F) ? true : false;

                Cmd             = m.ReadUInt16();
                CmdBufferStatus = m.ReadByte();

                OneWireWriteBufferStatus = m.ReadByte();
                OneWireReadBufferStatus  = m.ReadByte();

                var rsvd2 = m.ReadByte();
                var rsvd3 = m.ReadByte();

                var len = length - 16;
                if (len > 0)
                {
                    byte[] buff = new byte[len];
                    for (int i = 0; i < len; i++)
                    {
                        buff[i] = m.ReadByte();
                    }
                    CommResultCodes = buff;
                }
                else
                {
                    CommResultCodes = null;
                }

                Updated = true;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: nehori/PtSim
 private void SetEnabled(EnableFlags flags)
 {
     buttonExecute.Enabled                  = (flags & EnableFlags.Execute) == EnableFlags.Execute;
     buttonPerformance.Enabled              = (flags & EnableFlags.Result) == EnableFlags.Result;
     buttonHistory.Enabled                  = (flags & EnableFlags.History) == EnableFlags.History;
     deleteLogToolStripMenuItem.Enabled     = (flags & EnableFlags.DeleteLog) == EnableFlags.DeleteLog;
     deleteLogAllToolStripMenuItem.Enabled  = (flags & EnableFlags.DeleteLogAll) == EnableFlags.DeleteLogAll;
     brandListEditToolStripMenuItem.Enabled = (flags & EnableFlags.EditBrandList) == EnableFlags.EditBrandList;
 }
コード例 #3
0
 public BooksController(IBookRepository repository,
                        IRepository <BookAuthor> repositoryBookAuthor,
                        IMapper mapper,
                        ILogger <BooksController> logger,
                        IOptions <EnableFlags> options)
 {
     this.repository           = repository;
     this.repositoryBookAuthor = repositoryBookAuthor;
     this.mapper      = mapper;
     this.logger      = logger;
     this.enableFlags = options.Value;
 }
コード例 #4
0
        public formMaskOverlay(Process p, IntPtr window, EnableFlags flags)
        {
            SetStyle(ControlStyles.Opaque, true);

            this.process = p;
            this.flags   = flags;

            this.BackColor       = Color.Black;
            this.ShowInTaskbar   = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.StartPosition   = FormStartPosition.Manual;

            this.attachedTo = window;
        }
コード例 #5
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Name", false, out subEle))
            {
                if (Name == null)
                {
                    Name = new SimpleSubrecord <String>();
                }

                Name.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Type", false, out subEle))
            {
                if (Type == null)
                {
                    Type = new SimpleSubrecord <MediaSetType>();
                }

                Type.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Loop_Battle_DayOuter", false, out subEle))
            {
                if (Loop_Battle_DayOuter == null)
                {
                    Loop_Battle_DayOuter = new SimpleSubrecord <String>();
                }

                Loop_Battle_DayOuter.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Explore_DayMiddle", false, out subEle))
            {
                if (Explore_DayMiddle == null)
                {
                    Explore_DayMiddle = new SimpleSubrecord <String>();
                }

                Explore_DayMiddle.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Suspense_DayInner", false, out subEle))
            {
                if (Suspense_DayInner == null)
                {
                    Suspense_DayInner = new SimpleSubrecord <String>();
                }

                Suspense_DayInner.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("NightOuter", false, out subEle))
            {
                if (NightOuter == null)
                {
                    NightOuter = new SimpleSubrecord <String>();
                }

                NightOuter.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("NightMiddle", false, out subEle))
            {
                if (NightMiddle == null)
                {
                    NightMiddle = new SimpleSubrecord <String>();
                }

                NightMiddle.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("NightInner", false, out subEle))
            {
                if (NightInner == null)
                {
                    NightInner = new SimpleSubrecord <String>();
                }

                NightInner.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Decibel/Loop_Battle_DayOuter", false, out subEle))
            {
                if (DecibelLoop_Battle_DayOuter == null)
                {
                    DecibelLoop_Battle_DayOuter = new SimpleSubrecord <Single>();
                }

                DecibelLoop_Battle_DayOuter.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Decibel/Explore_DayMiddle", false, out subEle))
            {
                if (DecibelExplore_DayMiddle == null)
                {
                    DecibelExplore_DayMiddle = new SimpleSubrecord <Single>();
                }

                DecibelExplore_DayMiddle.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Decibel/Suspense_DayInner", false, out subEle))
            {
                if (DecibelSuspense_DayInner == null)
                {
                    DecibelSuspense_DayInner = new SimpleSubrecord <Single>();
                }

                DecibelSuspense_DayInner.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Decibel/NightOuter", false, out subEle))
            {
                if (DecibelNightOuter == null)
                {
                    DecibelNightOuter = new SimpleSubrecord <Single>();
                }

                DecibelNightOuter.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Decibel/NightMiddle", false, out subEle))
            {
                if (DecibelNightMiddle == null)
                {
                    DecibelNightMiddle = new SimpleSubrecord <Single>();
                }

                DecibelNightMiddle.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Decibel/NightInner", false, out subEle))
            {
                if (DecibelNightInner == null)
                {
                    DecibelNightInner = new SimpleSubrecord <Single>();
                }

                DecibelNightInner.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Boundaries/DayOuter", false, out subEle))
            {
                if (DayOuterBoundary == null)
                {
                    DayOuterBoundary = new SimpleSubrecord <Single>();
                }

                DayOuterBoundary.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Boundaries/DayMiddle", false, out subEle))
            {
                if (DayMiddleBoundary == null)
                {
                    DayMiddleBoundary = new SimpleSubrecord <Single>();
                }

                DayMiddleBoundary.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Boundaries/DayInner", false, out subEle))
            {
                if (DayInnerBoundary == null)
                {
                    DayInnerBoundary = new SimpleSubrecord <Single>();
                }

                DayInnerBoundary.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Boundaries/NightOuter", false, out subEle))
            {
                if (NightOuterBoundary == null)
                {
                    NightOuterBoundary = new SimpleSubrecord <Single>();
                }

                NightOuterBoundary.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Boundaries/NightMiddle", false, out subEle))
            {
                if (NightMiddleBoundary == null)
                {
                    NightMiddleBoundary = new SimpleSubrecord <Single>();
                }

                NightMiddleBoundary.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Boundaries/NightInner", false, out subEle))
            {
                if (NightInnerBoundary == null)
                {
                    NightInnerBoundary = new SimpleSubrecord <Single>();
                }

                NightInnerBoundary.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EnableFlags", false, out subEle))
            {
                if (EnableFlags == null)
                {
                    EnableFlags = new SimpleSubrecord <MediaSetEnableFlags>();
                }

                EnableFlags.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("WaitTime_MinTimeOn_DaytimeMin", false, out subEle))
            {
                if (WaitTime_MinTimeOn_DaytimeMin == null)
                {
                    WaitTime_MinTimeOn_DaytimeMin = new SimpleSubrecord <Single>();
                }

                WaitTime_MinTimeOn_DaytimeMin.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin", false, out subEle))
            {
                if (LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin == null)
                {
                    LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin = new SimpleSubrecord <Single>();
                }

                LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("RecoveryTime_LayerCrossfadeTime_DaytimeMax", false, out subEle))
            {
                if (RecoveryTime_LayerCrossfadeTime_DaytimeMax == null)
                {
                    RecoveryTime_LayerCrossfadeTime_DaytimeMax = new SimpleSubrecord <Single>();
                }

                RecoveryTime_LayerCrossfadeTime_DaytimeMax.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("NighttimeMax", false, out subEle))
            {
                if (NighttimeMax == null)
                {
                    NighttimeMax = new SimpleSubrecord <Single>();
                }

                NighttimeMax.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Intro_Daytime", false, out subEle))
            {
                if (Intro_Daytime == null)
                {
                    Intro_Daytime = new RecordReference();
                }

                Intro_Daytime.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Outro_Nighttime", false, out subEle))
            {
                if (Outro_Nighttime == null)
                {
                    Outro_Nighttime = new RecordReference();
                }

                Outro_Nighttime.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Unknown", false, out subEle))
            {
                if (Unknown == null)
                {
                    Unknown = new SimpleSubrecord <Byte[]>();
                }

                Unknown.ReadXML(subEle, master);
            }
        }
コード例 #6
0
        public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (EditorID != null)
            {
                ele.TryPathTo("EditorID", true, out subEle);
                EditorID.WriteXML(subEle, master);
            }
            if (Name != null)
            {
                ele.TryPathTo("Name", true, out subEle);
                Name.WriteXML(subEle, master);
            }
            if (Type != null)
            {
                ele.TryPathTo("Type", true, out subEle);
                Type.WriteXML(subEle, master);
            }
            if (Loop_Battle_DayOuter != null)
            {
                ele.TryPathTo("Loop_Battle_DayOuter", true, out subEle);
                Loop_Battle_DayOuter.WriteXML(subEle, master);
            }
            if (Explore_DayMiddle != null)
            {
                ele.TryPathTo("Explore_DayMiddle", true, out subEle);
                Explore_DayMiddle.WriteXML(subEle, master);
            }
            if (Suspense_DayInner != null)
            {
                ele.TryPathTo("Suspense_DayInner", true, out subEle);
                Suspense_DayInner.WriteXML(subEle, master);
            }
            if (NightOuter != null)
            {
                ele.TryPathTo("NightOuter", true, out subEle);
                NightOuter.WriteXML(subEle, master);
            }
            if (NightMiddle != null)
            {
                ele.TryPathTo("NightMiddle", true, out subEle);
                NightMiddle.WriteXML(subEle, master);
            }
            if (NightInner != null)
            {
                ele.TryPathTo("NightInner", true, out subEle);
                NightInner.WriteXML(subEle, master);
            }
            if (DecibelLoop_Battle_DayOuter != null)
            {
                ele.TryPathTo("Decibel/Loop_Battle_DayOuter", true, out subEle);
                DecibelLoop_Battle_DayOuter.WriteXML(subEle, master);
            }
            if (DecibelExplore_DayMiddle != null)
            {
                ele.TryPathTo("Decibel/Explore_DayMiddle", true, out subEle);
                DecibelExplore_DayMiddle.WriteXML(subEle, master);
            }
            if (DecibelSuspense_DayInner != null)
            {
                ele.TryPathTo("Decibel/Suspense_DayInner", true, out subEle);
                DecibelSuspense_DayInner.WriteXML(subEle, master);
            }
            if (DecibelNightOuter != null)
            {
                ele.TryPathTo("Decibel/NightOuter", true, out subEle);
                DecibelNightOuter.WriteXML(subEle, master);
            }
            if (DecibelNightMiddle != null)
            {
                ele.TryPathTo("Decibel/NightMiddle", true, out subEle);
                DecibelNightMiddle.WriteXML(subEle, master);
            }
            if (DecibelNightInner != null)
            {
                ele.TryPathTo("Decibel/NightInner", true, out subEle);
                DecibelNightInner.WriteXML(subEle, master);
            }
            if (DayOuterBoundary != null)
            {
                ele.TryPathTo("Boundaries/DayOuter", true, out subEle);
                DayOuterBoundary.WriteXML(subEle, master);
            }
            if (DayMiddleBoundary != null)
            {
                ele.TryPathTo("Boundaries/DayMiddle", true, out subEle);
                DayMiddleBoundary.WriteXML(subEle, master);
            }
            if (DayInnerBoundary != null)
            {
                ele.TryPathTo("Boundaries/DayInner", true, out subEle);
                DayInnerBoundary.WriteXML(subEle, master);
            }
            if (NightOuterBoundary != null)
            {
                ele.TryPathTo("Boundaries/NightOuter", true, out subEle);
                NightOuterBoundary.WriteXML(subEle, master);
            }
            if (NightMiddleBoundary != null)
            {
                ele.TryPathTo("Boundaries/NightMiddle", true, out subEle);
                NightMiddleBoundary.WriteXML(subEle, master);
            }
            if (NightInnerBoundary != null)
            {
                ele.TryPathTo("Boundaries/NightInner", true, out subEle);
                NightInnerBoundary.WriteXML(subEle, master);
            }
            if (EnableFlags != null)
            {
                ele.TryPathTo("EnableFlags", true, out subEle);
                EnableFlags.WriteXML(subEle, master);
            }
            if (WaitTime_MinTimeOn_DaytimeMin != null)
            {
                ele.TryPathTo("WaitTime_MinTimeOn_DaytimeMin", true, out subEle);
                WaitTime_MinTimeOn_DaytimeMin.WriteXML(subEle, master);
            }
            if (LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin != null)
            {
                ele.TryPathTo("LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin", true, out subEle);
                LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin.WriteXML(subEle, master);
            }
            if (RecoveryTime_LayerCrossfadeTime_DaytimeMax != null)
            {
                ele.TryPathTo("RecoveryTime_LayerCrossfadeTime_DaytimeMax", true, out subEle);
                RecoveryTime_LayerCrossfadeTime_DaytimeMax.WriteXML(subEle, master);
            }
            if (NighttimeMax != null)
            {
                ele.TryPathTo("NighttimeMax", true, out subEle);
                NighttimeMax.WriteXML(subEle, master);
            }
            if (Intro_Daytime != null)
            {
                ele.TryPathTo("Intro_Daytime", true, out subEle);
                Intro_Daytime.WriteXML(subEle, master);
            }
            if (Outro_Nighttime != null)
            {
                ele.TryPathTo("Outro_Nighttime", true, out subEle);
                Outro_Nighttime.WriteXML(subEle, master);
            }
            if (Unknown != null)
            {
                ele.TryPathTo("Unknown", true, out subEle);
                Unknown.WriteXML(subEle, master);
            }
        }
コード例 #7
0
 public override void WriteData(ESPWriter writer)
 {
     if (EditorID != null)
     {
         EditorID.WriteBinary(writer);
     }
     if (Name != null)
     {
         Name.WriteBinary(writer);
     }
     if (Type != null)
     {
         Type.WriteBinary(writer);
     }
     if (Loop_Battle_DayOuter != null)
     {
         Loop_Battle_DayOuter.WriteBinary(writer);
     }
     if (Explore_DayMiddle != null)
     {
         Explore_DayMiddle.WriteBinary(writer);
     }
     if (Suspense_DayInner != null)
     {
         Suspense_DayInner.WriteBinary(writer);
     }
     if (NightOuter != null)
     {
         NightOuter.WriteBinary(writer);
     }
     if (NightMiddle != null)
     {
         NightMiddle.WriteBinary(writer);
     }
     if (NightInner != null)
     {
         NightInner.WriteBinary(writer);
     }
     if (DecibelLoop_Battle_DayOuter != null)
     {
         DecibelLoop_Battle_DayOuter.WriteBinary(writer);
     }
     if (DecibelExplore_DayMiddle != null)
     {
         DecibelExplore_DayMiddle.WriteBinary(writer);
     }
     if (DecibelSuspense_DayInner != null)
     {
         DecibelSuspense_DayInner.WriteBinary(writer);
     }
     if (DecibelNightOuter != null)
     {
         DecibelNightOuter.WriteBinary(writer);
     }
     if (DecibelNightMiddle != null)
     {
         DecibelNightMiddle.WriteBinary(writer);
     }
     if (DecibelNightInner != null)
     {
         DecibelNightInner.WriteBinary(writer);
     }
     if (DayOuterBoundary != null)
     {
         DayOuterBoundary.WriteBinary(writer);
     }
     if (DayMiddleBoundary != null)
     {
         DayMiddleBoundary.WriteBinary(writer);
     }
     if (DayInnerBoundary != null)
     {
         DayInnerBoundary.WriteBinary(writer);
     }
     if (NightOuterBoundary != null)
     {
         NightOuterBoundary.WriteBinary(writer);
     }
     if (NightMiddleBoundary != null)
     {
         NightMiddleBoundary.WriteBinary(writer);
     }
     if (NightInnerBoundary != null)
     {
         NightInnerBoundary.WriteBinary(writer);
     }
     if (EnableFlags != null)
     {
         EnableFlags.WriteBinary(writer);
     }
     if (WaitTime_MinTimeOn_DaytimeMin != null)
     {
         WaitTime_MinTimeOn_DaytimeMin.WriteBinary(writer);
     }
     if (LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin != null)
     {
         LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin.WriteBinary(writer);
     }
     if (RecoveryTime_LayerCrossfadeTime_DaytimeMax != null)
     {
         RecoveryTime_LayerCrossfadeTime_DaytimeMax.WriteBinary(writer);
     }
     if (NighttimeMax != null)
     {
         NighttimeMax.WriteBinary(writer);
     }
     if (Intro_Daytime != null)
     {
         Intro_Daytime.WriteBinary(writer);
     }
     if (Outro_Nighttime != null)
     {
         Outro_Nighttime.WriteBinary(writer);
     }
     if (Unknown != null)
     {
         Unknown.WriteBinary(writer);
     }
 }
コード例 #8
0
        public override void ReadData(ESPReader reader, long dataEnd)
        {
            while (reader.BaseStream.Position < dataEnd)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "EDID":
                    if (EditorID == null)
                    {
                        EditorID = new SimpleSubrecord <String>();
                    }

                    EditorID.ReadBinary(reader);
                    break;

                case "FULL":
                    if (Name == null)
                    {
                        Name = new SimpleSubrecord <String>();
                    }

                    Name.ReadBinary(reader);
                    break;

                case "NAM1":
                    if (Type == null)
                    {
                        Type = new SimpleSubrecord <MediaSetType>();
                    }

                    Type.ReadBinary(reader);
                    break;

                case "NAM2":
                    if (Loop_Battle_DayOuter == null)
                    {
                        Loop_Battle_DayOuter = new SimpleSubrecord <String>();
                    }

                    Loop_Battle_DayOuter.ReadBinary(reader);
                    break;

                case "NAM3":
                    if (Explore_DayMiddle == null)
                    {
                        Explore_DayMiddle = new SimpleSubrecord <String>();
                    }

                    Explore_DayMiddle.ReadBinary(reader);
                    break;

                case "NAM4":
                    if (Suspense_DayInner == null)
                    {
                        Suspense_DayInner = new SimpleSubrecord <String>();
                    }

                    Suspense_DayInner.ReadBinary(reader);
                    break;

                case "NAM5":
                    if (NightOuter == null)
                    {
                        NightOuter = new SimpleSubrecord <String>();
                    }

                    NightOuter.ReadBinary(reader);
                    break;

                case "NAM6":
                    if (NightMiddle == null)
                    {
                        NightMiddle = new SimpleSubrecord <String>();
                    }

                    NightMiddle.ReadBinary(reader);
                    break;

                case "NAM7":
                    if (NightInner == null)
                    {
                        NightInner = new SimpleSubrecord <String>();
                    }

                    NightInner.ReadBinary(reader);
                    break;

                case "NAM8":
                    if (DecibelLoop_Battle_DayOuter == null)
                    {
                        DecibelLoop_Battle_DayOuter = new SimpleSubrecord <Single>();
                    }

                    DecibelLoop_Battle_DayOuter.ReadBinary(reader);
                    break;

                case "NAM9":
                    if (DecibelExplore_DayMiddle == null)
                    {
                        DecibelExplore_DayMiddle = new SimpleSubrecord <Single>();
                    }

                    DecibelExplore_DayMiddle.ReadBinary(reader);
                    break;

                case "NAM0":
                    if (DecibelSuspense_DayInner == null)
                    {
                        DecibelSuspense_DayInner = new SimpleSubrecord <Single>();
                    }

                    DecibelSuspense_DayInner.ReadBinary(reader);
                    break;

                case "ANAM":
                    if (DecibelNightOuter == null)
                    {
                        DecibelNightOuter = new SimpleSubrecord <Single>();
                    }

                    DecibelNightOuter.ReadBinary(reader);
                    break;

                case "BNAM":
                    if (DecibelNightMiddle == null)
                    {
                        DecibelNightMiddle = new SimpleSubrecord <Single>();
                    }

                    DecibelNightMiddle.ReadBinary(reader);
                    break;

                case "CNAM":
                    if (DecibelNightInner == null)
                    {
                        DecibelNightInner = new SimpleSubrecord <Single>();
                    }

                    DecibelNightInner.ReadBinary(reader);
                    break;

                case "JNAM":
                    if (DayOuterBoundary == null)
                    {
                        DayOuterBoundary = new SimpleSubrecord <Single>();
                    }

                    DayOuterBoundary.ReadBinary(reader);
                    break;

                case "KNAM":
                    if (DayMiddleBoundary == null)
                    {
                        DayMiddleBoundary = new SimpleSubrecord <Single>();
                    }

                    DayMiddleBoundary.ReadBinary(reader);
                    break;

                case "LNAM":
                    if (DayInnerBoundary == null)
                    {
                        DayInnerBoundary = new SimpleSubrecord <Single>();
                    }

                    DayInnerBoundary.ReadBinary(reader);
                    break;

                case "MNAM":
                    if (NightOuterBoundary == null)
                    {
                        NightOuterBoundary = new SimpleSubrecord <Single>();
                    }

                    NightOuterBoundary.ReadBinary(reader);
                    break;

                case "NNAM":
                    if (NightMiddleBoundary == null)
                    {
                        NightMiddleBoundary = new SimpleSubrecord <Single>();
                    }

                    NightMiddleBoundary.ReadBinary(reader);
                    break;

                case "ONAM":
                    if (NightInnerBoundary == null)
                    {
                        NightInnerBoundary = new SimpleSubrecord <Single>();
                    }

                    NightInnerBoundary.ReadBinary(reader);
                    break;

                case "PNAM":
                    if (EnableFlags == null)
                    {
                        EnableFlags = new SimpleSubrecord <MediaSetEnableFlags>();
                    }

                    EnableFlags.ReadBinary(reader);
                    break;

                case "DNAM":
                    if (WaitTime_MinTimeOn_DaytimeMin == null)
                    {
                        WaitTime_MinTimeOn_DaytimeMin = new SimpleSubrecord <Single>();
                    }

                    WaitTime_MinTimeOn_DaytimeMin.ReadBinary(reader);
                    break;

                case "ENAM":
                    if (LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin == null)
                    {
                        LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin = new SimpleSubrecord <Single>();
                    }

                    LoopFadeOut_LoopingRandomCrossfadeOverlap_NighttimeMin.ReadBinary(reader);
                    break;

                case "FNAM":
                    if (RecoveryTime_LayerCrossfadeTime_DaytimeMax == null)
                    {
                        RecoveryTime_LayerCrossfadeTime_DaytimeMax = new SimpleSubrecord <Single>();
                    }

                    RecoveryTime_LayerCrossfadeTime_DaytimeMax.ReadBinary(reader);
                    break;

                case "GNAM":
                    if (NighttimeMax == null)
                    {
                        NighttimeMax = new SimpleSubrecord <Single>();
                    }

                    NighttimeMax.ReadBinary(reader);
                    break;

                case "HNAM":
                    if (Intro_Daytime == null)
                    {
                        Intro_Daytime = new RecordReference();
                    }

                    Intro_Daytime.ReadBinary(reader);
                    break;

                case "INAM":
                    if (Outro_Nighttime == null)
                    {
                        Outro_Nighttime = new RecordReference();
                    }

                    Outro_Nighttime.ReadBinary(reader);
                    break;

                case "DATA":
                    if (Unknown == null)
                    {
                        Unknown = new SimpleSubrecord <Byte[]>();
                    }

                    Unknown.ReadBinary(reader);
                    break;

                default:
                    throw new Exception();
                }
            }
        }
コード例 #9
0
 /// <summary>
 /// Parse the AUX_CLIENT_CONTROL structure.
 /// </summary>
 /// <param name="s">A stream containing the AUX_CLIENT_CONTROL structure</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.EnableFlags = (EnableFlags)ReadUint();
     this.ExpiryTime = ReadUint();
 }
コード例 #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            #region Configuration

            EnableFlags enableFlags = new EnableFlags();
            this.Configuration.GetSection("Features:EnableFlags").Bind(enableFlags);

            AuthOptions authOptions = new AuthOptions();
            this.Configuration.GetSection("Authentication").Bind(authOptions);

            services.Configure <EnableFlags>(this.Configuration.GetSection("Features:EnableFlags"));
            services.Configure <AuthAuthenticationOptions>(o => { o.Scheme = authOptions.Schema; });

            services.Configure <IpRateLimitOptions>((options =>
            {
                options.EnableEndpointRateLimiting = true;
                options.DisableRateLimitHeaders = true;
                options.StackBlockedRequests = false;
                options.IpWhitelist = new List <string>()
                {
                    "192.168.0.0/24"
                };
                //options.EndpointWhitelist = new List<string>() { "get:*api/v1/books*" };
                options.GeneralRules = new System.Collections.Generic.List <RateLimitRule>()
                {
                    new RateLimitRule()
                    {
                        Endpoint = "*",
                        Limit = 4,
                        Period = "1s"
                    },
                    new RateLimitRule()
                    {
                        Endpoint = "*",
                        Limit = 15,
                        Period = "1m"
                    },
                    new RateLimitRule()
                    {
                        Endpoint = "*",
                        Limit = 100,
                        Period = "15m"
                    }
                };
            }));
            #endregion

            #region LifeCycles
            #region Generics
            services.AddScoped(typeof(IRepository <>), typeof(RepositorySync <>));
            services.AddScoped(typeof(IPagedRepository <>), typeof(PagedRepository <>));
            #endregion

            services.AddScoped(typeof(IBookRepository), typeof(BookRepository));
            services.AddScoped(typeof(IAuthorRepository), typeof(AuthorRepository));
            services.AddScoped(typeof(LinkFilter));

            services.AddSingleton <IServiceSTS, ServiceSTS>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <IRateLimitConfiguration, RateLimitConfiguration>();
            services.AddSingleton <IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
            services.AddSingleton <IIpPolicyStore, MemoryCacheIpPolicyStore>();
            #endregion

            services.AddMvc(setup =>
            {
                setup.ReturnHttpNotAcceptable = true;
                setup.OutputFormatters.Add(new XmlSerializerOutputFormatter());
            })
            .ConfigureApiBehaviorOptions(o =>
            {
                o.InvalidModelStateResponseFactory = (actionContext) =>
                {
                    var errors = actionContext.ModelState.Values.Where(e => e.ValidationState != Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Valid).SelectMany(e => e.Errors).Select(e => e.Exception == null ? e.ErrorMessage : e.Exception.Message).ToArray();
                    var msg    = string.Join("| ", errors);

                    ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, "Error validating parameters", msg);
                    return(new BadRequestObjectResult(error));
                };
            })
            .AddJsonOptions(o => o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore)
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            if (enableFlags.UseSqlite)
            {
                services.AddDbContext <ApplicationDbContext>(o => o.UseSqlite($"Data Source={Environment.ContentRootPath}/dblibrary.db"));
            }
            else
            {
                services.AddDbContext <ApplicationDbContext>(o => o.UseSqlServer(Configuration.GetConnectionString("LibraryConnection"), options => options.CommandTimeout(60)));
            }

            services.AddAutoMapper(typeof(MapperProfile));

            services.AddApiVersioning((o =>
            {
                o.DefaultApiVersion = new ApiVersion(1, 0);
                o.ReportApiVersions = true;
                o.AssumeDefaultVersionWhenUnspecified = true;
                o.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("X-Version"), new QueryStringApiVersionReader("api-version"));
            }));

            services.AddMemoryCache();
            services.AddHttpClient();

            services.AddResponseWithLink();
            services.AddSTS(authOptions.Url);

            if (enableFlags.UseSwagger)
            {
                services.AddSwaggerGen(o =>
                {
                    o.SwaggerDoc("v1", new OpenApiInfo()
                    {
                        Title       = "Library API",
                        Description = "Sample Library API To Store Your Books",
                        Version     = "v1",
                        Contact     = new OpenApiContact
                        {
                            Name  = "José Christiano Viana Junior",
                            Email = "*****@*****.**",
                            Url   = new Uri("https://library-api.com"),
                        }
                    });
                    o.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
                    {
                        Scheme      = "Bearer",
                        In          = ParameterLocation.Header,
                        Type        = SecuritySchemeType.ApiKey,
                        Name        = "Authorization",
                        Description = "JWT authorization header"
                    });

                    o.AddSecurityRequirement(new OpenApiSecurityRequirement
                    {
                        {
                            new OpenApiSecurityScheme
                            {
                                Reference = new OpenApiReference {
                                    Type = ReferenceType.SecurityScheme, Id = "Bearer"
                                }
                            },
                            new List <string>()
                        }
                    });
                });
            }

            services.AddAuthentication(o =>
            {
                o.DefaultScheme          = AuthAuthenticationDefaults.Schema;
                o.DefaultChallengeScheme = AuthAuthenticationDefaults.Schema;
            }).AddScheme <AuthAuthenticationOptions, AuthAuthenticationHandler>(AuthAuthenticationDefaults.Schema, null);
        }