コード例 #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);
            }
        }
コード例 #2
0
ファイル: ConfigurationBase.cs プロジェクト: YFS11013/Synapse
 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;
 }
コード例 #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);
            }
        }
コード例 #4
0
ファイル: ConfigurationBase.cs プロジェクト: YFS11013/Synapse
 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;
 }
コード例 #5
0
ファイル: ConfigurationBase.cs プロジェクト: YFS11013/Synapse
 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;
 }
コード例 #6
0
ファイル: ConfigurationBase.cs プロジェクト: YFS11013/Synapse
 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;
 }
コード例 #7
0
ファイル: OBRConfiguration.cs プロジェクト: YFS11013/Synapse
        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));
        }
コード例 #8
0
 private void SelectProjectChange(object obj)
 {
     SelectedArea = ConfigAreasCollection.Where(e => e.ID == SelectedProject.ConfigAreaID).FirstOrDefault();
 }
コード例 #9
0
        private bool EntryExist(ConfigArea area, ConfigKey key)
        {
            var entryExist = _entries.Any(e => e.Area == area.Name && e.Key == key.Name);

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

            return(entry);
        }
コード例 #11
0
        private bool AreaExist(ConfigArea area)
        {
            var areaExist = _entries.Any(e => e.Area == area.Name);

            return(areaExist);
        }
コード例 #12
0
        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();
                }
            };
        }
コード例 #13
0
        public void UpdateConfigArea(ConfigArea configArea)
        {
            ConfigArea configAreasToUpdate = ConfigAreas.Where(e => e.ID.Equals(configArea.ID)).FirstOrDefault();

            configAreasToUpdate = configArea;
        }
コード例 #14
0
 public void DeleteConfigArea(ConfigArea configArea)
 {
     ConfigAreas.Remove(configArea);
 }
コード例 #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));
 }