예제 #1
0
        internal static string Format(object value, string format, out bool foundMatchingFormatter)
        {
            foundMatchingFormatter = false;

            if (value == null)
            {
                return(null);
            }

            if (format == null)
            {
                format = String.Empty;
            }

            ChoTypeObjectFormatInfo[] typeObjectsFormatInfo = ChoTypesManager.GetTypeObjectsFormatInfo();
            if (typeObjectsFormatInfo != null && typeObjectsFormatInfo.Length > 0)
            {
                foreach (ChoTypeObjectFormatInfo typeObjectFormatInfo in typeObjectsFormatInfo)
                {
                    if (typeObjectFormatInfo.CanFormat(value))
                    {
                        foundMatchingFormatter = true;
                        return(typeObjectFormatInfo.Format(value, format));
                    }
                }
            }

            return(null);
        }
예제 #2
0
        protected override void OnAfterCommandLineArgObjectLoaded(string[] commandLineArgs)
        {
            ChoShellExtensionActionMode?sem = GetShellExtensionActionMode();

            if (DisplayAvailProperties || DisplayAvailTypeParsersNFormatters)
            {
                if (DisplayAvailProperties)
                {
                    ChoApplication.DisplayMsg(ChoPropertyManagerSettings.Me.GetHelpText(), null, ConsoleColor.Yellow);
                }
                if (DisplayAvailTypeParsersNFormatters)
                {
                    ChoApplication.DisplayMsg(ChoTypesManager.GetHelpText(), null, ConsoleColor.Green);
                }
                if (!ConfigObjectTypeName.IsNullOrWhiteSpace())
                {
                    ChoApplication.DisplayMsg(ChoConfigurationManager.GetHelpText(ChoType.GetType(ConfigObjectTypeName)), null, ConsoleColor.Green);
                }
                Environment.Exit(0);
            }
            else if (!ConfigObjectTypeName.IsNullOrWhiteSpace())
            {
                ChoApplication.DisplayMsg(ChoConfigurationManager.GetHelpText(ChoType.GetType(ConfigObjectTypeName)), null, ConsoleColor.Green);
                Environment.Exit(0);
            }
            else if (sem != null)
            {
                if (sem.Value == ChoShellExtensionActionMode.Register)
                {
                    ChoShellExtension.Register();
                    ChoTrace.WriteLine("Shell Extensions registered successfully.");

                    ChoShellFileAssociation.Register();
                    ChoTrace.WriteLine("File Associations registered successfully.");

                    Environment.Exit(0);
                }
                else if (sem.Value == ChoShellExtensionActionMode.Unregister)
                {
                    ChoShellExtension.Unregister();
                    ChoTrace.WriteLine("Shell Extensions unregistered successfully.");

                    ChoShellFileAssociation.Unregister();
                    ChoTrace.WriteLine("File Associations unregistered successfully.");

                    Environment.Exit(0);
                }
            }

            if (ChoShellExtension.ExecuteShellExtensionMethodIfAnySpecified(commandLineArgs))
            {
                ChoTrace.WriteLine("Shell Extension ran successfully.");
                Environment.Exit(0);
            }

            base.OnAfterCommandLineArgObjectLoaded(commandLineArgs);
        }
예제 #3
0
        static ChoAppDomain()
        {
            //ChoApplication.Initialize();
            RegisterAppDomainEvents();
            string envPath = ChoEnvironmentSettings.GetConfigFilePath();
            ChoGlobalApplicationSettings x = ChoGlobalApplicationSettings.Me;

            ChoApplication.Refresh();
            ChoTypesManager.Initialize();
            ChoAbortableQueuedExecutionService asyncExecutionService = ChoAbortableQueuedExecutionService.Global;

            _Load();
        }
예제 #4
0
        public static object ToObject(string inString)
        {
            if (inString == null || inString.Trim().Length == 0)
            {
                return(null);
            }

            ChoTypeObjectParseInfo[] typeObjectsInfo = ChoTypesManager.GetTypeObjectsParseInfo();

            foreach (ChoTypeObjectParseInfo typeObjectInfo in typeObjectsInfo)
            {
                if (typeObjectInfo.CheckParse(inString))
                {
                    return(typeObjectInfo.Parse(inString));
                }
            }

            if (inString.IsInteger())
            {
                int intValue;

                if (Int32.TryParse(inString, out intValue))
                {
                    return(intValue);
                }

                long longValue;
                if (Int64.TryParse(inString, out longValue))
                {
                    return(longValue);
                }

                double doubleValue;
                if (Double.TryParse(inString, out doubleValue))
                {
                    return(doubleValue);
                }

                return(inString);
            }
            else if (inString.IsNumber())
            {
                return(double.Parse(inString));
            }
            else
            {
                return(inString);
            }
        }
예제 #5
0
        internal static object ToObjectInternal(string inString, Type targetType = null)
        {
            if (inString == null || inString.Trim().Length == 0)
            {
                return(null);
            }

            if (targetType != null && ChoTypesManager.TypeObjectsParseInfo.ContainsKey(targetType))
            {
                ChoTypeObjectParseInfo typeObjectInfo1 = ChoTypesManager.TypeObjectsParseInfo[targetType];
                if (typeObjectInfo1 == null)
                {
                    return(inString);
                }
                if (typeObjectInfo1.CheckParse(inString))
                {
                    return(typeObjectInfo1.Parse(inString));
                }
                else
                {
                    return(inString);
                }
            }

            ChoTypeObjectParseInfo[] typeObjectsInfo = ChoTypesManager.GetTypeObjectsParseInfo();

            foreach (ChoTypeObjectParseInfo typeObjectInfo in typeObjectsInfo)
            {
                if (typeObjectInfo.CheckParse(inString))
                {
                    return(typeObjectInfo.Parse(inString));
                }
            }

            return(inString);
        }