Esempio n. 1
0
        public void Set(ConfigArea area, ConfigKey key, object value, bool persist = false)
        {
            if (area == null)
            {
                throw new ArgumentNullException("area");
            }

            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            try
            {
                var entryExist = EntryExist(area, key);
                if (entryExist)
                {
                    var entry = GetEntry(area, key);
                    entry.Value   = value;
                    entry.Persist = persist;
                }
                else
                {
                    var entry = new ConfigEntry(area.Name, key.Name, value, persist);
                    _entries.Add(entry);
                }
            }
            catch (Exception e)
            {
                var message = String.Format("Error setting value {0} for key {1} in area {2} ({3})",
                                            value, key.Name, area.Name, persist ? "persistent" : "non-persistent");
                throw new ConfigurationException(message, e);
            }
        }
Esempio n. 2
0
 public ConfigurationBase(ConfigurationBase initializationData)
 {
     Title = initializationData.Title;
     this.mainConfigType = initializationData.GetMainConfigType;
     this.configArea     = initializationData.GetConfigArea;
     ValueDataType       = initializationData.ValueDataType;
     Typography          = initializationData.Typography;
     ValueRepresentation = initializationData.ValueRepresentation;
     ValueEditType       = initializationData.ValueEditType;
     this.configRange    = initializationData.configRange;
 }
Esempio n. 3
0
        public T Get <T>(ConfigArea area, ConfigKey key)
        {
            if (area == null)
            {
                throw new ArgumentNullException("area");
            }

            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var areaExist = AreaExist(area);

            if (!areaExist)
            {
                throw new AreaNotFoundException("Can't find area " + area.Name);
            }

            var keyExist = EntryExist(area, key);

            if (!keyExist)
            {
                var message = String.Format("Can't find key {0} ind area {1}", key.Name, area.Name);
                throw new KeyNotFoundException(message);
            }

            try
            {
                var entry = GetEntry(area, key);

                var typeToReturn  = typeof(T);
                var typeOfValue   = entry.Value.GetType();
                var typesAreEqual = typeToReturn == typeOfValue;
                if (!typesAreEqual)
                {
                    var message = String.Format("Can't convert source type {0} to requested type {1}", typeOfValue,
                                                typeToReturn);
                    throw new InvalidTypeException(message);
                }

                return((T)(object)entry.Value);
            }
            catch (InvalidTypeException)
            {
                throw;
            }
            catch (Exception e)
            {
                var message = String.Format("Can't get a value for {0} in area {1}", area.Name, key.Name);
                throw new ConfigurationException(message, e);
            }
        }
Esempio n. 4
0
 public ConfigurationBase(string title, MainConfigType mainConfigType, ConfigArea configArea, ValueDataType valueDataType, Typography typography, ValueRepresentation valueRepresentation, ValueEditType valueEditType, ConfigRange configRange, int processingIndex)
 {
     Title = title;
     this.mainConfigType = mainConfigType;
     this.configArea     = configArea;
     ValueDataType       = valueDataType;
     Typography          = typography;
     ValueRepresentation = valueRepresentation;
     ValueEditType       = valueEditType;
     this.configRange    = configRange;
     ProcessingIndex     = processingIndex;
 }
Esempio n. 5
0
 public ConfigurationBase(BaseData baseData)
 {
     Title = baseData.title;
     this.mainConfigType = baseData.mainConfigType;
     this.configArea     = baseData.configArea;
     ValueDataType       = baseData.valueDataType;
     Typography          = baseData.typography;
     ValueRepresentation = baseData.valueRepresentation;
     ValueEditType       = baseData.valueEditType;
     this.configRange    = baseData.configRange;
     ProcessingIndex     = baseData.processingIndex;
 }
Esempio n. 6
0
 public BaseData(ConfigurationBase initializationData)
 {
     title                = initializationData.Title;
     mainConfigType       = initializationData.GetMainConfigType;
     configArea           = initializationData.GetConfigArea;
     valueDataType        = initializationData.ValueDataType;
     typography           = initializationData.Typography;
     valueRepresentation  = initializationData.ValueRepresentation;
     valueEditType        = initializationData.ValueEditType;
     configRange          = initializationData.configRange;
     this.processingIndex = initializationData.ProcessingIndex;
 }
Esempio n. 7
0
        public static OBRConfiguration CreateDefault(string regionName, ConfigArea configArea, int processingIndex)
        {
            BaseData baseData = new BaseData(regionName, MainConfigType.BARCODE, configArea, ValueDataType.Text, Typography.Continious, ValueRepresentation.Collective, ValueEditType.ReadOnly, new ConfigRange(), processingIndex);

            return(new OBRConfiguration(baseData, FBarcodeType.cibfCode128, true, EBarcodeAlgorithm.cibBestRecognition));
        }
 private void SelectProjectChange(object obj)
 {
     SelectedArea = ConfigAreasCollection.Where(e => e.ID == SelectedProject.ConfigAreaID).FirstOrDefault();
 }
Esempio n. 9
0
        private bool EntryExist(ConfigArea area, ConfigKey key)
        {
            var entryExist = _entries.Any(e => e.Area == area.Name && e.Key == key.Name);

            return(entryExist);
        }
Esempio n. 10
0
        private ConfigEntry GetEntry(ConfigArea area, ConfigKey key)
        {
            var entry = _entries.Single(e => e.Area == area.Name && e.Key == key.Name);

            return(entry);
        }
Esempio n. 11
0
        private bool AreaExist(ConfigArea area)
        {
            var areaExist = _entries.Any(e => e.Area == area.Name);

            return(areaExist);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_cradle_config_area);

            JoyaTouchCradleApplication application = (JoyaTouchCradleApplication)ApplicationContext;

            jtCradle = application.CradleJoyaTouch;

            if (savedInstanceState == null)
            {
                ConfigArea config = new ConfigArea();
                if (jtCradle.ReadConfigArea(config))
                {
                    configValues = config.GetContent();
                }
                else
                {
                    Toast.MakeText(this, "Failure reading config area. Retry.", ToastLength.Long).Show();
                }
            }
            else
            {
                configValues = savedInstanceState.GetByteArray("configValues");
            }

            ConfigAreaAdapter adapter = new ConfigAreaAdapter(this, configValues);

            grid         = (GridView)FindViewById(Resource.Id.configValuesGrid);
            grid.Adapter = adapter;

            // handle read button
            Button readButton = FindViewById <Button>(Resource.Id.buttonReadConfig);

            readButton.Click += delegate
            {
                ConfigArea config = new ConfigArea();
                if (jtCradle.ReadConfigArea(config))
                {
                    configValues = config.GetContent();
                    ConfigAreaAdapter aTemp = new ConfigAreaAdapter(this, configValues);
                    grid.Adapter = aTemp;
                    grid.Invalidate();
                }
                else
                {
                    Toast.MakeText(this, "Failure reading config area. Retry.", ToastLength.Long).Show();
                }
            };

            // handle write button
            Button writeButton = FindViewById <Button>(Resource.Id.buttonWriteConfig);

            writeButton.Click += delegate
            {
                ConfigArea config = new ConfigArea(configValues);
                if (jtCradle.WriteConfigArea(config))
                {
                    Toast.MakeText(this, "Config data written successfully.", ToastLength.Long).Show();
                }
                else
                {
                    Toast.MakeText(this, "Failure writing config area. Retry.", ToastLength.Long).Show();
                }
            };
        }
        public void UpdateConfigArea(ConfigArea configArea)
        {
            ConfigArea configAreasToUpdate = ConfigAreas.Where(e => e.ID.Equals(configArea.ID)).FirstOrDefault();

            configAreasToUpdate = configArea;
        }
 public void DeleteConfigArea(ConfigArea configArea)
 {
     ConfigAreas.Remove(configArea);
 }
Esempio n. 15
0
 public static ICRConfiguration CreateDefault(string regionName, ConfigArea configArea, int processingIndex)
 {
     ConfigurationBase.BaseData baseData = new ConfigurationBase.BaseData(regionName, MainConfigType.ICR, configArea, ValueDataType.Integer, Typography.Continious, ValueRepresentation.Collective, ValueEditType.ReadOnly, new ConfigRange(), processingIndex);
     return(new ICRConfiguration(baseData));
 }