Ejemplo n.º 1
0
        protected override string FormatValueAsString(TValue value)
        {
            // Avoiding a cast to IFormattable to avoid boxing.
            switch (value)
            {
            case null:
                return(null);

            case int @int:
                return(BindConverter.FormatValue(@int, CultureInfo.InvariantCulture));

            case long @long:
                return(BindConverter.FormatValue(@long, CultureInfo.InvariantCulture));

            case short @short:
                return(BindConverter.FormatValue(@short, CultureInfo.InvariantCulture));

            case float @float:
                return(BindConverter.FormatValue(@float, CultureInfo.InvariantCulture));

            case double @double:
                return(BindConverter.FormatValue(@double, CultureInfo.InvariantCulture));

            case decimal @decimal:
                return(BindConverter.FormatValue(@decimal, CultureInfo.InvariantCulture));

            default:
                throw new InvalidOperationException($"Unsupported type {value.GetType()}");
            }
        }
Ejemplo n.º 2
0
        public AnalyticsSystem Add <TValue>()  where TValue : IAnalyticSystem, new()
        {
            var    system = new TValue();
            string key    = system.GetType().ToString();

            if (_managedSystem.ContainsKey(key))
            {
                Debug.LogErrorFormat("System {0} already exist", key);
                return(this);
            }
            _managedSystem.Add(key, system);
            return(this);
        }
 public string GetLink(TValue value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     try {
         return(_valueToPath[value]);
     }
     catch (KeyNotFoundException e) {
         throw new JsonLinkProviderException("Object '{0}' of type '{1}' (id={2}) is not a valid link as it is not contained within the root object."
                                             .Fmt(value, value.GetType(), _linkProvider.GetDebugId(value)), e);
     }
 }