예제 #1
0
        public void AddOrReplacePlugInGroup(string plugInGroupName, string xml)
        {
            ChoGuard.ArgumentNotNullOrEmpty(plugInGroupName, "PlugInGroupName");

            XDocument doc = XDocument.Parse(xml);

            if (PlugInsGroupDict.ContainsKey(plugInGroupName))
            {
                PlugInsGroupDict[plugInGroupName] = doc.Root;
            }
            else
            {
                PlugInsGroupDict.Add(plugInGroupName, doc.Root);
            }
        }
예제 #2
0
        public static void Serialize(string path, object target)
        {
            ChoGuard.ArgumentNotNullOrEmpty(path, "Path");
            ChoGuard.ArgumentNotNull(target, "Target");

            ChoDirectory.CreateDirectoryFromFilePath(path);

            using (FileStream f = File.OpenWrite(path))
            {
                if (target != null)
                {
                    new BinaryFormatter().Serialize(f, target);
                }
            }
        }
예제 #3
0
        public string[] GetDependsOn(Type type, string memberName)
        {
            ChoGuard.ArgumentNotNull(type, "Type");
            ChoGuard.ArgumentNotNullOrEmpty(memberName, "MemberName");

            Register(type);
            if (!_cache.ContainsKey(type) ||
                !_cache[type].ContainsKey(memberName) ||
                _cache[type][memberName] == null)
            {
                return new String[] { }
            }
            ;

            return(_cache[type][memberName].ToArray());
        }
    }
예제 #4
0
        public static void Remove(Type type, string formatName)
        {
            ChoGuard.ArgumentNotNullOrEmpty(type, "Type");
            ChoGuard.ArgumentNotNullOrEmpty(formatName, "FormatName");

            if (!_objectFormatHandlers.ContainsKey(type) ||
                !_objectFormatHandlers[type].ContainsKey(formatName))
            {
                return;
            }

            lock (_padLock)
            {
                if (!_objectFormatHandlers.ContainsKey(type) ||
                    !_objectFormatHandlers[type].ContainsKey(formatName))
                {
                    return;
                }

                _objectFormatHandlers[type].Remove(formatName);
            }
        }
예제 #5
0
        public ChoTypeShortNameAttribute(string name)
        {
            ChoGuard.ArgumentNotNullOrEmpty(name, "Name");

            _name = name;
        }
예제 #6
0
 public ChoMessageBox(string detailErrMsg, string errMsg = null, string title = null)
 {
     ChoGuard.ArgumentNotNullOrEmpty(detailErrMsg, "DetailErrMsg");
     InitializeComponent();
     Initialize(detailErrMsg, errMsg, title);
 }
예제 #7
0
 public void Save(string plugInsDefFilePath)
 {
     ChoGuard.ArgumentNotNullOrEmpty(plugInsDefFilePath, "PlugInsDefFilePath");
     File.WriteAllText(plugInsDefFilePath, ToXml());
 }
예제 #8
0
 protected override void Validate()
 {
     base.Validate();
     ChoGuard.ArgumentNotNullOrEmpty(Script, "Script");
 }
예제 #9
0
 protected virtual void Validate()
 {
     ChoGuard.ArgumentNotNullOrEmpty(Name, "Name");
 }
예제 #10
0
 protected override void Validate()
 {
     base.Validate();
     ChoGuard.ArgumentNotNullOrEmpty(TypeName, "TypeName");
     ChoGuard.ArgumentNotNullOrEmpty(MethodName, "MethodName");
 }
예제 #11
0
 public ChoNameableObject(string name)
 {
     ChoGuard.ArgumentNotNullOrEmpty(name, "Name");
     Name = name;
 }
예제 #12
0
 public static IEnumerable <ChoPlugInBuilder> LoadFrom(TextReader plugInDefStream)
 {
     ChoGuard.ArgumentNotNullOrEmpty(plugInDefStream, "PlugInDefStream");
     return(Load(plugInDefStream));
 }
        public ChoStringObjectFormattableAttribute(Type supportedType)
        {
            ChoGuard.ArgumentNotNullOrEmpty(supportedType, "SupportedType");

            SupportedType = supportedType;
        }
예제 #14
0
        private static void Initialize()
        {
            if (_isInitialized)
            {
                return;
            }

            lock (_padLock)
            {
                if (_isInitialized)
                {
                    return;
                }

                _logBackupDay = DateTime.Today;

                InitializeAppInfo();

                if (!ServiceInstallation)
                {
                    if (ApplicationMode != ChoApplicationMode.Service &&
                        ApplicationMode != ChoApplicationMode.Web)
                    {
                        try
                        {
                            _rkAppRun = Registry.CurrentUser.OpenSubKey(RegRunSubKey, true);
                            if (_rkAppRun == null)
                            {
                                _rkAppRun = Registry.CurrentUser.CreateSubKey(RegRunSubKey);
                            }

                            RunAtSystemStartup(!ChoGlobalApplicationSettings.Me.ApplicationBehaviourSettings.RunAtStartup);
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Trace.TraceError(ex.ToString());
                        }

                        try
                        {
                            _rkAppRunOnce = Registry.CurrentUser.OpenSubKey(RegRunOnceSubKey, true);
                            if (_rkAppRunOnce == null)
                            {
                                _rkAppRunOnce = Registry.CurrentUser.CreateSubKey(RegRunOnceSubKey);
                            }

                            RunOnceAtSystemStartup(!ChoGlobalApplicationSettings.Me.ApplicationBehaviourSettings.RunOnceAtStartup);
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Trace.TraceError(ex.ToString());
                        }
                    }
                }

                ChoGuard.ArgumentNotNullOrEmpty(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath, "Application Config Path");

                try
                {
                    _elApplicationEventLog        = new EventLog("Application", Environment.MachineName, ChoGlobalApplicationSettings.Me.ApplicationName);
                    _elApplicationEventLog.Log    = "Application";
                    _elApplicationEventLog.Source = ChoGlobalApplicationSettings.Me.EventLogSourceName;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.TraceError(ex.ToString());
                }

                ApplicationConfigDirectory = Path.GetDirectoryName(ChoGlobalApplicationSettings.Me.ApplicationConfigFilePath);

                //Add default text trace listerner, if not defined in the configuration file
                Directory.CreateDirectory(ChoApplication.ApplicationLogDirectory);
                try
                {
                    if (_logFileName != ChoGlobalApplicationSettings.Me.LogSettings.LogFileName ||
                        _logDirectory != ChoApplication.ApplicationLogDirectory)
                    {
                        _logFileName  = ChoGlobalApplicationSettings.Me.LogSettings.LogFileName;
                        _logDirectory = ChoApplication.ApplicationLogDirectory;

                        ChoTextWriterTraceListener frxTextWriterTraceListener = new Cinchoo.Core.Diagnostics.ChoTextWriterTraceListener("Cinchoo",
                                                                                                                                        String.Format("BASEFILENAME={0};DIRECTORYNAME={1};FILEEXT={2}", ChoGlobalApplicationSettings.Me.LogSettings.LogFileName,
                                                                                                                                                      ChoApplication.ApplicationLogDirectory, ChoReservedFileExt.Txt));

                        if (_frxTextWriterTraceListener != null)
                        {
                            System.Diagnostics.Trace.Listeners.Remove(_frxTextWriterTraceListener);
                        }
                        else
                        {
                            ChoGlobalTimerServiceManager.Register("Logbackup", () =>
                            {
                                if (DateTime.Today != _logBackupDay)
                                {
                                    _logBackupDay = DateTime.Today;
                                    ChoTrace.Backup();
                                }
                            }, 60000);
                        }

                        _frxTextWriterTraceListener = frxTextWriterTraceListener;
                        System.Diagnostics.Trace.Listeners.Add(_frxTextWriterTraceListener);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.TraceError(ex.ToString());
                }

                while (_queueTraceMsg.Count > 0)
                {
                    Tuple <bool?, string> tuple = _queueTraceMsg.Dequeue();
                    System.Diagnostics.Trace.WriteLineIf(tuple.Item1 == null ? ChoGlobalApplicationSettings.Me.TurnOnConsoleOutput : tuple.Item1.Value, tuple.Item2);
                }
                _isInitialized = true;

                ChoApplication.WriteToEventLog(ChoApplication.ToString());
                //ChoApplication.WriteToEventLog(ChoGlobalApplicationSettings.Me.ToString());

                //Initialize other Framework Settings
                ChoAssembly.Initialize();
                ChoConsole.Initialize();
                ChoConfigurationManager.Initialize();
            }
        }
예제 #15
0
 protected override void Validate()
 {
     base.Validate();
     ChoGuard.ArgumentNotNullOrEmpty(CodeSnippet, "CodeSnippet");
 }
예제 #16
0
 public ChoNameableObject(Type type)
 {
     ChoGuard.ArgumentNotNullOrEmpty(type, "Type");
     Name = type.FullName;
 }
예제 #17
0
        public ChoTypeAttribute(string typeName)
        {
            ChoGuard.ArgumentNotNullOrEmpty(typeName, "Type Name");

            Type = ChoType.GetType(typeName);
        }
예제 #18
0
        public ChoRegistrySectionAttribute1(string registryKey)
        {
            ChoGuard.ArgumentNotNullOrEmpty(registryKey, "RegistryKey");

            _registryKey = registryKey;
        }