public ConsumerSpecification(IEnumerable <IConsumerMessageSpecification <TConsumer> > messageSpecifications)
        {
            _messageTypes = messageSpecifications.ToDictionary(x => x.MessageType);
            _optionsSet   = new OptionsSet();

            _observers = new ConsumerConfigurationObservable();
            _handles   = _messageTypes.Values.Select(x => x.ConnectConsumerConfigurationObserver(_observers)).ToArray();
        }
Пример #2
0
        public virtual T GetOption <T>(int option)
        {
            EnsureNotDisposed();

            object value;

            if (OptionsSet.TryGetValue((SocketOpt)option, out value))
            {
                return((T)value);
            }
            return(default(T));
        }
        public void Read(object key, OptionsSet entry)
        {
            if (key is not ICustomAttributeProvider attributeProvider)
            {
                return;
            }
            foreach (object attribute in attributeProvider.GetCustomAttributes(true))
            {
                switch (attribute)
                {
                case GenerateIgnoreAttribute:
                    entry.Part.Ignore = true;
                    break;

                case GeneratePreferInterfacesAttribute:
                    entry.Part.PreferInterfaces = true;
                    break;

                case GenerateStrictAttribute strictAttribute:
                    entry.Part.Strict = strictAttribute.Strict;
                    break;

                case GenerateRenameAttribute renameAttribute:
                    entry.Part.ReplaceName[renameAttribute.Replace] = renameAttribute.With;
                    break;

                case GeneratePropertiesAsFieldsAttribute:
                    entry.Part.FieldsToProperties = false;
                    entry.Part.PropertiesToFields = true;
                    break;

                case GenerateFieldsAsPropertiesAttribute:
                    entry.Part.FieldsToProperties = true;
                    entry.Part.PropertiesToFields = false;
                    break;

                case GenerateFormatNamesAttribute formatNamesAttribute:
                    entry.Part.FormatNames = formatNamesAttribute.FormatNames;
                    break;

                case GenerateNoHeaderAttribute:
                    entry.Part.AddHeader = false;
                    break;

                case GenerateOnlySubTypesAttribute:
                    entry.Part.OnlySubTypes = true;
                    break;
                }
            }
        }
Пример #4
0
        public virtual async Task <int> MainAsync(string[] args)
        {
            var ret = -1;

            var Options = ParseOptions(args, out var OptionsSet);

            if (!Options.Valid())
            {
                OptionsSet.WriteOptionDescriptions(System.Console.Out);
            }
            else
            {
                ret = await MainAsync(Options)
                      .DefaultAwait()
                ;
            }

            return(ret);
        }
 public ServiceClientOptions()
 {
     _optionsSet = new OptionsSet();
 }
Пример #6
0
 public IndicatorMath(OptionsSet db)
 {
     this.db = db;
 }
Пример #7
0
            public static bool Load(string filename, string rule, MarketSet data)
            {
                OptionsSet opod = new OptionsSet();

                try
                {
                    opod.ReadXml(filename);
                }
                catch { return(false); }

                // disable data notifications
                data.QuoteTable.BeginLoadData();
                data.OptionTable.BeginLoadData();

                foreach (OptionsSet.QuotesTableRow row in opod.QuotesTable.Rows)
                {
                    DateTime timestamp;
                    string   symbol, name, currency;
                    double   last, change, open, low, high, bid, ask, volume, dvrate, hisvol;

                    try { symbol = row.Stock; }
                    catch { continue; }

                    try { name = row.Name; }
                    catch { name = row.Stock; }

                    try { currency = ""; }
                    catch { currency = ""; }

                    try { last = row.Last; }
                    catch { continue; }

                    try { change = row.Change; }
                    catch { change = double.NaN; }

                    try { open = row.Open; }
                    catch { open = double.NaN; }

                    try { low = row.Low; }
                    catch { low = double.NaN; }

                    try { high = row.High; }
                    catch { high = double.NaN; }

                    try { bid = row.Bid; }
                    catch { bid = double.NaN; }

                    try { ask = row.Ask; }
                    catch { ask = double.NaN; }

                    try { volume = row.Volume; }
                    catch { volume = double.NaN; }

                    try { dvrate = row.DividendRate; }
                    catch { dvrate = double.NaN; }

                    try { hisvol = row.HistoricalVolatility; }
                    catch { hisvol = double.NaN; }

                    try { timestamp = row.UpdateTimeStamp; }
                    catch { timestamp = DateTime.Now; }

                    // delete old entry in option table
                    DataRow del = data.QuoteTable.FindBySymbol(symbol);
                    if (del != null)
                    {
                        del.Delete();
                    }

                    // add new entry to quote table
                    data.QuoteTable.AddQuoteTableRow(
                        symbol, name, currency, last, change, open, low, high,
                        bid, ask, volume, dvrate, timestamp, hisvol);
                }

                foreach (OptionsSet.OptionsTableRow row in opod.OptionsTable.Rows)
                {
                    int      openint;
                    DateTime expiration, timestamp;
                    string   symbol, underlying, type;
                    double   strike, last, change, bid, ask, volume, contract_size;

                    try { symbol = row.Symbol.TrimStart(new char[] { '.' }); }
                    catch { continue; }

                    try { underlying = row.Stock; }
                    catch { continue; }

                    try { type = row.Type; }
                    catch { continue; }

                    try { strike = row.Strike; }
                    catch { continue; }

                    try { expiration = row.Expiration; }
                    catch { continue; }

                    try { last = row.Last; }
                    catch { last = double.NaN; }

                    try { change = row.Change; }
                    catch { change = double.NaN; }

                    try { bid = row.Bid; }
                    catch { bid = double.NaN; }

                    try { ask = row.Ask; }
                    catch { ask = double.NaN; }

                    try { volume = row.Volume; }
                    catch { volume = double.NaN; }

                    try { openint = row.OpenInt; }
                    catch { openint = 0; }

                    try { contract_size = row.StocksPerContract; }
                    catch { contract_size = 1; }

                    try { timestamp = row.UpdateTimeStamp; }
                    catch { timestamp = DateTime.Now; }

                    // delete old entry in option table
                    DataRow del = data.OptionTable.FindBySymbol(symbol);
                    if (del != null)
                    {
                        del.Delete();
                    }

                    // add new entry to option table
                    data.OptionTable.AddOptionTableRow(
                        symbol, underlying, type, strike, expiration,
                        last, change, bid, ask, volume, openint, contract_size, timestamp);
                }

                // enable data notifications
                data.QuoteTable.EndLoadData();
                data.OptionTable.EndLoadData();
                data.AcceptChanges();

                return(true);
            }