Ejemplo n.º 1
0
        public XmlCurrencyDataSource(XmlDataStore dataStore)
        {
            DbC.ThrowIfArgumentNull(dataStore, "dataStore");

            var ds = (SingleDataSource)dataStore.GetData(Name).SingleOrDefault();

            myCurrencyTable = (CurrencyTable)ds.Value;
        }
Ejemplo n.º 2
0
        public void AddCar(Car car)
        {
            var stringBuilder   = new StringBuilder();
            var serializeObject = _jsonSerialize.SerializeObject(car);

            DbC.Require(() => serializeObject != null, "No se ha serializado");

            stringBuilder.Append(serializeObject);

            FileUtilities.CreateFolderIfNotExists(_path);

            File.AppendAllText(Path.Combine(_path, "data.txt"), stringBuilder.ToString());
            stringBuilder.Clear();
        }
Ejemplo n.º 3
0
        public void SetDiFiFmax(Di?di, FiFmax?fiFmax)
        {
            DbC.Assure((di.HasValue && fiFmax.HasValue) ||
                       (di.HasValue == false && fiFmax.HasValue == false), "di and fi/fmax must be either both defined or undefined");

            if (di.HasValue && fiFmax.HasValue)
            {
                this.SetInterfaceByte(0, InterfaceByteType.Ta, CodingUtils.NibbleToByte((byte)fiFmax, (byte)di));
            }
            else
            {
                this.SetInterfaceByte(0, InterfaceByteType.Ta, null);
            }
            this.InvokePropertyChanged(nameof(GlobalInterfaceBytes.Di));
            this.InvokePropertyChanged(nameof(GlobalInterfaceBytes.DiValue));
            this.InvokePropertyChanged(nameof(GlobalInterfaceBytes.FiFmax));
            this.InvokePropertyChanged(nameof(GlobalInterfaceBytes.FiFmaxValue));
        }
Ejemplo n.º 4
0
        public void RemoveIndication()
        {
            DbC.Assure(this.IsOnlyIndicatedProtocol == false, "Last and only protocol inidication cannot be removed");

            foreach (AtrInterfaceByteGroupToken Group in this.Owner.TokenizedAtr.InterfaceByteGroups.ToArray())
            {
                if (Group.Type == (InterfaceByteGroupType)this.ProtocolType)
                {
                    if (Group.Number == 2)
                    {
                        //Special handling for group#2: instead of removal, type indication ahs to be changed to next protocol
                        this.Owner.TokenizedAtr.InterfaceByteGroups.ElementAt(0).NextInterfaceBytesIndicator.GroupType = this.Owner.TokenizedAtr.InterfaceByteGroups.Skip(2).First(_ => _.Type != (InterfaceByteGroupType)this.ProtocolType).Type;
                    }
                    else
                    {
                        this.Owner.TokenizedAtr.InterfaceByteGroups.Remove(Group);
                    }
                }
            }
            this.RemoveUnusedGroups();
        }
        /// <summary>
        /// Opens an explorer window that shows the directory and selected file of the given path
        /// </summary>
        public void OpenPathInExplorer(string path)
        {
            DbC.AssureArgumentNotNull(path, "path");

            string ExplorerExe = Path.Combine(Environment.GetEnvironmentVariable("windir") ?? "", "Explorer.exe");

            while (File.Exists(path) == false && Directory.Exists(path) == false)
            {
                path = Path.GetDirectoryName(path);
            }

            if (Directory.Exists(path))
            {
                //path is a directory
                path += "\\";
            }
            ProcessStartInfo ProcessInfo = new ProcessStartInfo(ExplorerExe);

            ProcessInfo.Arguments   = $@"/select, ""{path}""";
            ProcessInfo.WindowStyle = ProcessWindowStyle.Normal;
            Process.Start(ProcessInfo);
        }
Ejemplo n.º 6
0
 public bool ReleaseReference(ComponentContainer componentContainer)
 {
     DbC.Assure(this.references.Contains(componentContainer));
     this.references.Remove(componentContainer);
     return(this.references.Count == 0);
 }
 public byte GetAsByte(byte lowerNibble)
 {
     DbC.Assure((lowerNibble & 0xF0) == 0x00);
     return((byte)(lowerNibble | (this.TaExists ? 0x10 : 0x00) | (this.TbExists ? 0x20 : 0x00) | (this.TcExists ? 0x40 : 0x00) | (this.TdExists ? 0x80 : 0x00)));
 }
 public ReadRecord(byte shortFileId, byte lengthToRead)
 {
     DbC.Assure((shortFileId & 0xE0) == 0x00, "Short file ID for read record can only have values from 0 to 31");
     this.ShortFileId  = shortFileId;
     this.LengthToRead = lengthToRead;
 }
 public ReadBinary(byte shortFileId, byte lengthToRead)
 {
     DbC.Assure((shortFileId & 0xF0) == 0x00, "Short file ID for read binary can only have values from 0 to 15");
     this.ShortFileId  = shortFileId;
     this.LengthToRead = lengthToRead;
 }
Ejemplo n.º 10
0
 public void RemoveNextGroup()
 {
     DbC.AssureNotNull(this.NextGroup);
     this.owner.InterfaceByteGroups.Remove(this.NextGroup);
 }