Exemplo n.º 1
0
        private async void AddReaderButton_ClickHandler(object sender, RoutedEventArgs e)
        {
            try
            {
                IsBusy = true;

                int       previousCount = Readers.Count;
                IRunnable runnable      = UseServiceBus ? (IRunnable) new ServiceBusReader() : new EventHubsReader();

                if (!Settings.DisableRunning)
                {
                    await runnable.Start().ConfigureAwait(false);
                }

                Readers.Add(runnable);

                Data.RecordSettingChange("Reader Count", previousCount, Readers.Count);
            }
            catch (Exception ex)
            {
                Data.Error("MainWindow", "Failed to start reader.", ex);
            }
            finally
            {
                IsBusy = false;
                _rebuildPartitionOwners = true;
            }
        }
Exemplo n.º 2
0
        public static ShapefileReader ReadShapefile(string path)
        {
            ShapefileReader shpfileReader = null;

            try
            {
                if (ValidShapefileParts(path))
                {
                    shpfileReader = new ShapefileReader(path, true);
                    Readers.Add(shpfileReader);
                }
                else
                {
                    throw new Exception("Missing shapefile components at " + path);
                }
            }
            catch (Exception e)
            {
                ReaderExceptions.Add(e);
                shpfileReader = null;
            }
            finally
            {
                if (shpfileReader != null)
                {
                    shpfileReader.CloseFileStream();
                }
            }
            return(shpfileReader);
        }
        void UpdateReaderList(List <INamedReader> list)
        {
            var unchangedAvailables = Readers.Join(list, x => x.DisplayName, y => y.DisplayName, (x, y) => x);
            var unchangedPaired     = Readers.Join(list, x => x.DisplayName, y => y.DisplayName, (x, y) => y);

            Readers.Except(unchangedAvailables).FirstOrDefault(p => Readers.Remove(p) && false);
            list.Except(unchangedPaired).FirstOrDefault(p => { Readers.Add(p); return(false); });
        }
 void ISecureConfigurationStore.AllowAccessFrom(IHaveServiceIdentity serviceIdentity)
 {
     if (Readers.Any(r => r.Id == serviceIdentity.Id))
     {
         return;
     }
     Readers.Add(serviceIdentity);
 }
Exemplo n.º 5
0
        public void RegisterReadingDevice(string vendorName, string model, string version,
                                          string serialNumber, string description, IReaderModule module)
        {
            var device = new ReaderDevice(vendorName, model, version, serialNumber, description, module);

            AllJoynDsbServiceManager.Current.AddDevice(device);
            _readers.Add(device);
            module.ValueChanged += _conditionManager.ReaderModule_ValueChanged;
            Readers.Add(module);
        }
        private void LoadReaders()
        {
            Readers.Clear();
            IEnumerable <Reader> readers = context.Readers.AsEnumerable().ToList();

            foreach (Reader item in readers)
            {
                Readers.Add(item);
            }
        }
Exemplo n.º 7
0
 public void FromXML(XElement xmlElement)
 {
     foreach (var element in xmlElement.Descendants("Author"))
     {
         Authors.Add((string)element.Value);
     }
     foreach (var element in xmlElement.Descendants("Reader"))
     {
         Readers.Add((string)element.Value);
     }
 }
Exemplo n.º 8
0
        public override Readers GetSections(string name)
        {
            var result = new Readers();

            foreach (var reader in sections)
            {
                if (reader.Name == name)
                {
                    result.Add(reader);
                }
            }

            return(result);
        }
Exemplo n.º 9
0
 public bool AddReader(IApplicationReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException();
     }
     if (!ReaderExists(reader.Login))
     {
         Readers.Add(reader);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 10
0
        private void ParseAndAddReader
        (
            MarcRecord record
        )
        {
            ReaderInfo reader = ReaderInfo.Parse(record);
            string     status = reader.Status;

            if (string.IsNullOrEmpty(status))
            {
                reader.Status = "0";
                status        = "0";
            }
            Readers.Add(reader);
            ReadersByStatus.Add(status, reader);
        }
Exemplo n.º 11
0
 public bool AddReader(string login, string password)
 {
     if (String.IsNullOrEmpty(login) || String.IsNullOrEmpty(password))
     {
         throw new ArgumentNullException();
     }
     if (!ReaderExists(login))
     {
         Readers.Add(new Reader(login, password));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 12
0
 private void UpdateReaderList(object parameter)
 {
     Readers.Clear();
     EventHistory.Clear();
     using (var ctx = _contextFactory.Establish(SCardScope.System)) {
         foreach (var reader in ctx.GetReaders())
         {
             Readers.Add(reader);
         }
     }
     _subscription?.Dispose();
     if (Readers.Count > 0)
     {
         _subscription = _monitorFactory
                         .CreateObservable(SCardScope.System, Readers)
                         .ObserveOn(_uiScheduler) // Important! Monitor does not run on UI thread.
                         .Subscribe(OnNext, OnError);
     }
 }
Exemplo n.º 13
0
        private void _AnalyzeReader
        (
            [CanBeNull] ReaderInfo reader
        )
        {
            if (!ReferenceEquals(reader, null))
            {
                Readers.Add(reader);

                if (reader.Status == "0")
                {
                    DebtorInfo debtor
                        = _debtorManager.GetDebtor(reader);
                    if (!ReferenceEquals(debtor, null))
                    {
                        Debtors.Add(debtor);
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void TimesInitialize()
        {
            if (!IsInitialized)
            {
                InputDateTimeIO   = new DateTimeIO("%Y/%m/%d %H:%M:%S", true);
                TimelogDateTimeIO = new DateTimeIO("%m/%d/%Y %H:%M:%S", true);

                WrittenDateTimeIO = new DateTimeIO("%Y/%m/%d %H:%M:%S", false);
                WrittenDateIO     = new DateIO("%Y/%m/%d", false);

                PrintedDateTimeIO = new DateTimeIO("%y-%b-%d %H:%M:%S", false);
                PrintedDateIO     = new DateIO("%y-%b-%d", false);

                Readers.Add(new DateIO("%m/%d", true));
                Readers.Add(new DateIO("%Y/%m/%d", true));
                Readers.Add(new DateIO("%Y/%m", true));
                Readers.Add(new DateIO("%y/%m/%d", true));
                Readers.Add(new DateIO("%Y-%m-%d", true));

                IsInitialized = true;
            }
        }
Exemplo n.º 15
0
        public Formatter()
        {
            Binder            = null;
            Context           = new StreamingContext();
            SurrogateSelector = null;

            Readers.Add("json", DeserializeJson);
            Readers.Add("png", DeserializeImage);
            Readers.Add("tif", DeserializeImage);
            Readers.Add("jpg", DeserializeImage);
            Readers.Add("gif", DeserializeImage);
            Readers.Add("bmp", DeserializeImage);
            SignatureReaders.Add("42 4D", "bmp");                       // .bmp
            SignatureReaders.Add("47 49 46 38 37 61", "gif");           // .gif
            SignatureReaders.Add("47 49 46 38 39 61", "gif");           // .gif
            SignatureReaders.Add("FF D8 FF E0", "jpg");                 // .jpg
            SignatureReaders.Add("FF D8 FF E1", "jpg");                 // .jpg
            SignatureReaders.Add("49 49 2A 00", "tif");                 // .tif
            SignatureReaders.Add("4D 4D 00 2A", "tif");                 // .tif
            SignatureReaders.Add("89 50 4E 47 0D 0A 1A 0A", "png");     // .png
            SignatureReaders.Add("{", "json");
            SignatureReaders.Add("[", "json");
        }
Exemplo n.º 16
0
 public void RegisterReader(string name, Action <BinaryReader> reader) => Readers.Add(name, reader);
Exemplo n.º 17
0
        internal ServiceConfig()
        {
            for (int i = 8; i < 13; i++)
            {
                var reader = new Reader
                {
                    Comment    = $"\n        Readers should be of format[Reader #] and TAG should be [Readers.Read_Tag_#]\n        i.e.Reader {i} \u21d4 Readers.Read_Tag_{i}\n      ",
                    Address    = IPAddress.Loopback.ToString(),
                    PortNum    = 6000,
                    ReaderName = $"Reader {i}",
                    Tags       = new Reader.ReaderTags()
                    {
                        ReaderTag = new Reader.ReaderTags.ReadTags()
                        {
                            ReadTag = $":RFID Readers.Readers.ReadTags.Read_Tag_{i}",
                            Note    = "Required, Type BOOLEAN"
                        },

                        WriterTag = new Reader.ReaderTags.WriteTags()
                        {
                            Note     = "Optional, Type BOOLEAN",
                            WriteTag = $"2:RFID Readers.Readers.WriteTags.Write_Tag_{i}"
                        },

                        UuidTag = new Reader.ReaderTags.UidTags()
                        {
                            Note    = "Required, Type STRING, Tag of unique ID of RFID Tag",
                            UuidTag = $"2:RFID Readers.Readers.UuidTags.Uuid_Tag_{i}"
                        },
                        ErrorTag = new Reader.ReaderTags.ErrorTags()
                        {
                            Note        = "Required, Used for Alarms and Events. Type BOOLEAN,STRING",
                            ErrorBool   = $"2:RFID Readers.Readers.AE.Error_B_Station_{i}",
                            ErrorString = $"2:RFID Readers.Readers.AE.Error_S_Station_{i}"
                        }
                    },
                    TimeOut = 10,
                    Uuid    = new Reader.Uid()
                    {
                        UidGuid = Guid.NewGuid(),
                        UidNote = "LEAVE THIS BLANK"
                    },
                    Active = false
                };
                Readers.Add(reader);
            }

            var opc = new OPC()
            {
                ServerAddress = IPAddress.Loopback.ToString(),
                ServerPort    = 49320,
                Auth          = new OPC.LogonAuth()
                {
                    Username       = "******",
                    Password       = "******",
                    AnonymousLogin = false,
                    Note           = "Provide either Username and Password OR AnonymousLogin as true"
                }
            };

            Server.Add(opc);
        }
Exemplo n.º 18
0
 public void Add(ClientInformation client)
 {
     Readers.Add(ClientInformation.Convert(client));
     Readers.Save();
 }
Exemplo n.º 19
0
 public void RegisterReader(PulsarMod plugin, Action <BinaryReader> reader) => Readers.Add(plugin.Name, reader);
Exemplo n.º 20
0
        private object LoadAssetWithDynamicContentReader <T>(string assetName, Stream stream, object options)
        {
            object result;
            var    type = typeof(T);

            var parameters = new ContentReaderParameters
            {
                AssetName = assetName,
                AssetType = type,
                Stream    = stream,
                Options   = options
            };

            try
            {
                IContentReader contentReader;
                lock (registeredContentReaders)
                {
                    if (!registeredContentReaders.TryGetValue(type, out contentReader))
                    {
                        // Use registered factories to handle a type
                        lock (registeredContentReaderFactories)
                        {
                            foreach (var factory in registeredContentReaderFactories)
                            {
                                contentReader = factory.TryCreate(type);
                                if (contentReader != null)
                                {
                                    registeredContentReaders.Add(type, contentReader);
                                    break;
                                }
                            }
                        }

                        // Else tries to get a ContentReaderAttribute to resolve the type
                        if (contentReader == null)
                        {
#if WIN8METRO
                            var contentReaderAttribute = Utilities.GetCustomAttribute <ContentReaderAttribute>(type.GetTypeInfo(), true);
#else
                            var contentReaderAttribute = Utilities.GetCustomAttribute <ContentReaderAttribute>(type, true);
#endif

                            if (contentReaderAttribute != null)
                            {
                                contentReader = Activator.CreateInstance(contentReaderAttribute.ContentReaderType) as IContentReader;
                                if (contentReader != null)
                                {
                                    Readers.Add(typeof(T), contentReader);
                                }
                            }
                        }
                    }
                }

                if (contentReader == null)
                {
                    throw new NotSupportedException(string.Format("Type [{0}] doesn't provide a ContentReaderAttribute, and there is no registered content reader/factory for it.", type.FullName));
                }

                result = contentReader.ReadContent(this, ref parameters);

                if (result == null)
                {
                    throw new NotSupportedException(string.Format("Registered ContentReader of type [{0}] fails to load content of type [{1}] from file [{2}].", contentReader.GetType(), type.FullName, assetName));
                }
            }
            finally
            {
                // If we don't need to keep the stream open, then we can close it
                // and make sure that we will close the stream even if there is an exception.
                if (!parameters.KeepStreamOpen)
                {
                    stream.Dispose();
                }
            }

            return(result);
        }
Exemplo n.º 21
0
 public void RegisterReaderAndWriter(string name, Action <BinaryReader> reader, Action <BinaryWriter> writer)
 {
     Readers.Add(name, reader); Writers.Add(name, writer);
 }
Exemplo n.º 22
0
 public void RegisterReaderAndWriter(PulsarMod plugin, Action <BinaryReader> reader, Action <BinaryWriter> writer)
 {
     Readers.Add(plugin.Name, reader); Writers.Add(plugin.Name, writer);
 }
 public SummarizeVariable(Action <TimeArg <I> > action) : base()
 {
     Readers.Add(action);
 }