Esempio n. 1
0
        /// <summary>
        /// Database Store property.
        /// </summary>


        #endregion

        #region Default Constructor method.

        /// <summary>
        /// Default Constructor method.
        /// </summary>
        /// <param name="publicClientId">Public client ID parameter</param>
        public AppOAuthProvider(string publicClientId)
        {
            //TODO: Pull from configuration
            if (publicClientId == null)
            {
                throw new ArgumentNullException(NameOf.nameof(() => publicClientId));
            }

            // Settings.
            _publicClientId = publicClientId;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                if (CommandLine.Parser.Default.ParseArguments(args, CMDParameters))
                {
                    if (CMDParameters.IsBatch)
                    {
                        // Enable file and console logging.
                        CLogger.ConfigureRollingFileAppender();
                        CLogger.AddAppender(typeof(Program).ToString(), CLogger.GetColoredConsoleAppender());
                    }
                    else
                    {
                        // Enable console logging.
                        CLogger.ConfigureColoredConsoleAppender();
                    }

                    Log.Info("===== " + Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetEntryAssembly().GetName().Version + " =====");

                    if (args.Count() == 0)
                    {
                        Console.WriteLine(CMDParameters.GetUsage());
                    }
                    else if (args.Count() == 1 && CMDParameters.IsBatch == true)
                    {
                        Log.Warn("Missing input parameters.");
                    }
                    else
                    {
                        doActionAccordingToParams(args);
                    }
                }
                else
                {
                    throw new ArgumentNullException(NameOf.nameof(() => CMDParameters), "All CMDParameters should not be null.");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            finally
            {
                // if is called from batch mode, remove any required user input.
                if (!CMDParameters.IsBatch)
                {
                    Console.WriteLine("Press the ENTER key to close the program.");
                    Console.ReadLine();
                }
                Log.Info("============= " + "END" + " =============");
            }
        }
        public static int FindSync(IList <byte> tsData, int offset, int TsPacketSize)
        {
            if (tsData == null)
            {
                throw new ArgumentNullException(NameOf.nameof(() => tsData));
            }

            //not big enough to be any kind of single TS packet
            if (tsData.Count < 188)
            {
                return(-1);
            }

            try
            {
                for (var i = offset; i < tsData.Count; i++)
                {
                    //check to see if we found a sync byte
                    if (tsData[i] != SyncByte)
                    {
                        continue;
                    }
                    if (i + 1 * TsPacketSize < tsData.Count && tsData[i + 1 * TsPacketSize] != SyncByte)
                    {
                        continue;
                    }
                    if (i + 2 * TsPacketSize < tsData.Count && tsData[i + 2 * TsPacketSize] != SyncByte)
                    {
                        continue;
                    }
                    if (i + 3 * TsPacketSize < tsData.Count && tsData[i + 3 * TsPacketSize] != SyncByte)
                    {
                        continue;
                    }
                    if (i + 4 * TsPacketSize < tsData.Count && tsData[i + 4 * TsPacketSize] != SyncByte)
                    {
                        continue;
                    }
                    // seems to be ok
                    return(i);
                }
                return(-1);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Problem in FindSync algorithm... : ", ex.Message);
                throw;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Does the action according to parameters.
 /// </summary>
 /// <param name="args">The arguments.</param>
 private static void doActionAccordingToParams(string[] args)
 {
     if (CMDParameters.fileLst != null && CMDParameters.fileLst.Count() > 0)
     {
         // One/multiple files with command switch.
         //Parallel.ForEach(CMDParameters.fileLst, (file) =>
         foreach (var file in CMDParameters.fileLst)
         {
             String extension = Path.GetExtension(file);
             if (String.IsNullOrEmpty(extension) || extension != @".yaml")
             {
                 throw new Exception("File: " + file + " has wrong extension, it should end with '.yaml'.");
             }
         }
         CWebClient.CheckUpWebsiteWithYAML(CMDParameters.fileLst);
     }
     else if (CMDParameters.urlLst != null && CMDParameters.urlLst.Count() > 0)
     {
         // It's a manual parameter. (command switch with Urls)
         CWebClient.CheckUpWebsiteWithConsoleCommand(CMDParameters.urlLst);
     }
     else if (CMDParameters.fileDragDropLst != null && CMDParameters.fileDragDropLst.Count() > 0)
     {
         // One/multiple files with drag'n'drop.
         //Parallel.ForEach(CMDParameters.fileDragDropLst, (file) =>
         foreach (var file in CMDParameters.fileDragDropLst)
         {
             String extension = Path.GetExtension(file);
             if (String.IsNullOrEmpty(extension) || extension != @".yaml")
             {
                 throw new Exception("File: " + file + " has wrong extension, it should end with '.yaml'.");
             }
         }
         CWebClient.CheckUpWebsiteWithYAML(CMDParameters.fileDragDropLst);
     }
     else
     {
         throw new ArgumentNullException(NameOf.nameof(() => CMDParameters), "All CMDParameters should not be null.");
     }
 }
        private static long Get_TimeStamp(int code, IList <byte> data, int offs)
        {
            if (data == null)
            {
                throw new ArgumentNullException(NameOf.nameof(() => data));
            }

            if (code == 0)
            {
                Debug.WriteLine("Method has been called with incorrect code to match against - check for fault in calling method.");
                throw new Exception("PES Syntax error: 0 value timestamp code check passed in");
            }

            if ((data[offs + 0] >> 4) != code)
            {
                throw new Exception("PES Syntax error: Wrong timestamp code");
            }

            if ((data[offs + 0] & 1) != 1)
            {
                throw new Exception("PES Syntax error: Invalid timestamp marker bit");
            }

            if ((data[offs + 2] & 1) != 1)
            {
                throw new Exception("PES Syntax error: Invalid timestamp marker bit");
            }

            if ((data[offs + 4] & 1) != 1)
            {
                throw new Exception("PES Syntax error: Invalid timestamp marker bit");
            }

            long a = (data[offs + 0] >> 1) & 7;
            long b = (data[offs + 1] << 7) | (data[offs + 2] >> 1);
            long c = (data[offs + 3] << 7) | (data[offs + 4] >> 1);

            return((a << 30) | (b << 15) | c);
        }
Esempio n. 6
0
            /// <summary>
            /// Deserializes the yaml.
            /// </summary>
            /// <param name="tr">The tr.</param>
            /// <returns></returns>
            /// <exception cref="System.ArgumentNullException"></exception>
            public static DTO_Header DeserializeYAML(TextReader tr)
            {
                try
                {
                    if (tr != null)
                    {
                        var deserializer = new DeserializerBuilder()
                                           .WithNodeDeserializer(inner => new ValidatingNodeDeserializer(inner), s => s.InsteadOf <ObjectNodeDeserializer>())
                                           .Build();

                        DTO_Header header = deserializer.Deserialize <DTO_Header>(tr);

                        return(header);
                    }
                    else
                    {
                        throw new ArgumentNullException(NameOf.nameof(() => tr), "The textreader object must not be null.");
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }