Example #1
0
        private void Awake()
        {
            var locator = new DictLocator();

            LocatorProvider.Init(locator);

            var vent = new MessageBus();

            locator.Set(MaruKeys.Random, new Random());
            locator.Set(MaruKeys.Vent, vent);
            locator.Set(MaruKeys.BinaryFormatter, new BinaryFormatter());
        }
Example #2
0
        /// <summary>
        /// Responsible for converting exceptions into <seealso cref="IExceptionEntry"/> object,
        /// gets the entry empty object and passes to <seealso cref="FormatException(System.Exception, Tavisca.Frameworks.Logging.IExceptionEntry)"/>
        /// The method calls <seealso cref="FormatException(Tavisca.Frameworks.Logging.IExceptionEntry)"/> at the end for
        /// final formatting, override this method only to change how an exception is converted to an entry.
        /// </summary>
        /// <param name="exception">The exception entry to be converted.</param>
        /// <returns>An <see cref="IExceptionEntry"/> object.</returns>
        public virtual IExceptionEntry FormatException(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            var entry = LocatorProvider.GetContainer().GetInstance <IExceptionEntry>();

            if (entry == null)
            {
                throw new LogConfigurationException("IExceptionEntry is not configured in the DI container.");
            }

            entry = FormatException(exception, entry);

            return(FormatException(entry));
        }
        protected virtual void Awake()
        {
            var vent = LocatorProvider.Get().Get(MaruKeys.Vent) as IMessageBus;

            off = new List <Action>(2);
            var key = GetInstanceID().ToString();

            off.Add(vent.On <SelectColorPickerPresetEvent>(key, PresetSelect));
            off.Add(vent.On <RemoveColorPickerPresetEvent>(key, RemovePreset));
            presetButtons = new Dictionary <int, GameObject>();

            picker.onHSVChanged.AddListener(HSVChanged);
            picker.onValueChanged.AddListener(ColorChanged);
            presetPrefab.SetActive(false);

            for (var i = 0; i < predefinedPresets.Length; i++)
            {
                presets.Add(new Tuple <int, Color>(i, predefinedPresets[i]));
            }

            LoadPresets(saveMode);
        }
 /// <summary>
 /// Sets the function that provides the value for the <see cref="ServiceLocator.Current" /> property.
 /// </summary>
 /// <param name="provider">The new provider.</param>
 public static void SetProvider(LocatorProvider provider)
 {
     _provider = provider;
 }
 private void Awake()
 {
     manager = new AdjustableUIManager(canvas);
     manager.Listen(LocatorProvider.Get().Get(MaruKeys.Vent) as IMessageBus);
 }
Example #6
0
 protected virtual ILogEntry GetLogEntry()
 {
     return(LocatorProvider.GetContainer().GetInstance <ITransactionEntry>());
 }
Example #7
0
 protected virtual ITraceLogger GetTraceLogFactory()
 {
     return(LocatorProvider.GetContainer().GetInstance <ITraceLogger>());
 }
Example #8
0
        protected static void LoadConfiguration(IApplicationLogSettings settings)
        {
            try
            {
                if (settings == null)
                {
                    throw new LogConfigurationException(LogResources.MissingConfiguration);
                }

                #region Custom Locator

                var providerType = settings.CustomLocatorAdapter;

                if (string.IsNullOrWhiteSpace(providerType))
                {
                    throw new LogConfigurationException(LogResources.Configuration_MissingCustomLocatorProvider);
                }

                var provider = GetServiceLocatorDelegate(providerType);

                LocatorProvider.SetLocator(provider);

                #endregion

                var taskFactory = TaskScheduling.Utility.GetTaskFactory(settings);

                var categories = new Dictionary <string, LoggerElementCollection>();

                foreach (CategoryElement category in settings.Categories)
                {
                    categories[category.Name] = category.Loggers;
                }

                if (!string.IsNullOrWhiteSpace(settings.CustomFormatter))
                {
                    var type = Type.GetType(settings.CustomFormatter);

                    if (type == null)
                    {
                        throw new LogConfigurationException(LogResources.Configuration_CustomFormatter_NotFound);
                    }

                    var formatter = Activator.CreateInstance(type) as ILogEntryFormatter;

                    if (formatter == null)
                    {
                        throw new LogConfigurationException(LogResources.Configuration_CustomFormatter_Invalid);
                    }

                    FormattingFactory.SetFormatter(formatter);
                }

                //Set Compression Provider
                Compression.ICompressionProvider compressionProvider;
                switch (settings.CompressionType)
                {
                case CompressionTypeOptions.Zip:
                    compressionProvider = new Compression.GZipCompressionProvider();
                    break;

                case CompressionTypeOptions.Deflate:
                    compressionProvider = new Compression.DeflateCompressionProvider();
                    break;

                case CompressionTypeOptions.Custom:

                    if (string.IsNullOrWhiteSpace(settings.CustomCompressionType))
                    {
                        throw new LogConfigurationException(LogResources.Configuration_CustomCompressionType_NotFound);
                    }

                    var type = Type.GetType(settings.CustomCompressionType);

                    if (type == null)
                    {
                        throw new LogConfigurationException(LogResources.Configuration_CustomCompressionType_NotFound);
                    }

                    compressionProvider = Activator.CreateInstance(type) as Compression.ICompressionProvider;

                    if (compressionProvider == null)
                    {
                        throw new LogConfigurationException(LogResources.Configuration_CustomCompressionType_Invalid);
                    }
                    break;

                default:
                    throw new LogConfigurationException(
                              string.Format(LogResources.CompressionType_NotSupported,
                                            Enum.GetName(typeof(CompressionTypeOptions), settings.CompressionType)));
                }

                Compression.CompressionProviderFactory.CurrentProvider = compressionProvider;

                LogSection  = settings;
                Categories  = categories;
                TaskFactory = taskFactory;

                FailSafeLogFactory.SetFailOverLoggingBehaviour(settings.ReThrowLogExceptions == SwitchOptions.On);
            }
            catch (LogConfigurationException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new LogConfigurationException(LogResources.LogConfigurationError_Generic, ex);
            }
        }
Example #9
0
 private void Awake()
 {
     colorPicker = GetComponent <ColorPickerControl>();
     vent        = LocatorProvider.Get().Get(MaruKeys.Vent) as IMessageBus;
     colorPicker.onValueChanged.AddListener(ColorPickerChanged);
 }
Example #10
0
 /// <summary>
 /// Gets an <see cref="ISink"/> by name using the DI container configured in the system.
 /// </summary>
 /// <param name="name">The name (key) of the logger.</param>
 /// <returns>An instance of an <see cref="ISink"/></returns>
 protected virtual ISink GetLoggerByName(string name)
 {
     return(LocatorProvider.GetContainer().GetInstance <ISink>(name));
 }
Example #11
0
 protected virtual IExceptionEntry GetEmptyExceptionEntry()
 {
     return(LocatorProvider.GetContainer().GetInstance <IExceptionEntry>());
 }
Example #12
0
 protected virtual IEntryStringTranslator GetTranslator()
 {
     return(LocatorProvider.GetContainer().GetInstance <IEntryStringTranslator>());
 }
Example #13
0
 public void Awake()
 {
     defaultScale = transform.localScale;
     vent         = LocatorProvider.Get().Get(MaruKeys.Vent) as IMessageBus;
 }
Example #14
0
 public void Awake()
 {
     defaultPosition = transform.position;
     vent            = LocatorProvider.Get().Get(MaruKeys.Vent) as IMessageBus;
 }
Example #15
0
 /// <summary>
 /// Sets the function that provides the value for the <see cref="ServiceLocator.Current" /> property.
 /// </summary>
 /// <param name="provider">The new provider.</param>
 public static void SetProvider(LocatorProvider provider)
 {
     _provider = provider;
 }