//------------------------------------------------------------------------------
// <auto-generated>
//     Dieser Code wurde von einem Tool generiert.
//     Laufzeitversion:4.0.30319.42000
//
//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
//     der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------

using NMF.Collections.Generic;
using NMF.Collections.ObjectModel;
using NMF.Expressions;
using NMF.Expressions.Linq;
using NMF.Models;
using NMF.Models.Collections;
using NMF.Models.Expressions;
using NMF.Serialization;
using NMF.Utilities;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;

namespace TTC2017.SmartGrids.CIM.IEC61970.Domain
{
    
    
    public class UnitMultiplierConverter : System.ComponentModel.TypeConverter
    {
        
        public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType)
        {
            return (sourceType == typeof(string));
        }
        
        public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType)
        {
            return (destinationType == typeof(string));
        }
        
        public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if ((value == null))
            {
                return default(UnitMultiplier);
            }
            string valueString = value.ToString();
            if ((valueString == "m"))
            {
                return UnitMultiplier.M;
            }
            if ((valueString == "p"))
            {
                return UnitMultiplier.P;
            }
            if ((valueString == "c"))
            {
                return UnitMultiplier.C;
            }
            if ((valueString == "T"))
            {
                return UnitMultiplier.T;
            }
            if ((valueString == "d"))
            {
                return UnitMultiplier.D;
            }
            if ((valueString == "k"))
            {
                return UnitMultiplier.K;
            }
            if ((valueString == "M"))
            {
                return UnitMultiplier.M1;
            }
            if ((valueString == "micro"))
            {
                return UnitMultiplier.Micro;
            }
            if ((valueString == "none"))
            {
                return UnitMultiplier.None;
            }
            if ((valueString == "n"))
            {
                return UnitMultiplier.N;
            }
            if ((valueString == "G"))
            {
                return UnitMultiplier.G;
            }
            return default(UnitMultiplier);
        }
        
        public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType)
        {
            if ((value == null))
            {
                return null;
            }
            UnitMultiplier valueCasted = ((UnitMultiplier)(value));
            if ((valueCasted == UnitMultiplier.M))
            {
                return "m";
            }
            if ((valueCasted == UnitMultiplier.P))
            {
                return "p";
            }
            if ((valueCasted == UnitMultiplier.C))
            {
                return "c";
            }
            if ((valueCasted == UnitMultiplier.T))
            {
                return "T";
            }
            if ((valueCasted == UnitMultiplier.D))
            {
                return "d";
            }
            if ((valueCasted == UnitMultiplier.K))
            {
                return "k";
            }
            if ((valueCasted == UnitMultiplier.M1))
            {
                return "M";
            }
            if ((valueCasted == UnitMultiplier.Micro))
            {
                return "micro";
            }
            if ((valueCasted == UnitMultiplier.None))
            {
                return "none";
            }
            if ((valueCasted == UnitMultiplier.N))
            {
                return "n";
            }
            if ((valueCasted == UnitMultiplier.G))
            {
                return "G";
            }
            throw new ArgumentOutOfRangeException("value");
        }
    }
}

