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); } }
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); } } }
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()); } }
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); } }
public ChoTypeShortNameAttribute(string name) { ChoGuard.ArgumentNotNullOrEmpty(name, "Name"); _name = name; }
public ChoMessageBox(string detailErrMsg, string errMsg = null, string title = null) { ChoGuard.ArgumentNotNullOrEmpty(detailErrMsg, "DetailErrMsg"); InitializeComponent(); Initialize(detailErrMsg, errMsg, title); }
public void Save(string plugInsDefFilePath) { ChoGuard.ArgumentNotNullOrEmpty(plugInsDefFilePath, "PlugInsDefFilePath"); File.WriteAllText(plugInsDefFilePath, ToXml()); }
protected override void Validate() { base.Validate(); ChoGuard.ArgumentNotNullOrEmpty(Script, "Script"); }
protected virtual void Validate() { ChoGuard.ArgumentNotNullOrEmpty(Name, "Name"); }
protected override void Validate() { base.Validate(); ChoGuard.ArgumentNotNullOrEmpty(TypeName, "TypeName"); ChoGuard.ArgumentNotNullOrEmpty(MethodName, "MethodName"); }
public ChoNameableObject(string name) { ChoGuard.ArgumentNotNullOrEmpty(name, "Name"); Name = name; }
public static IEnumerable <ChoPlugInBuilder> LoadFrom(TextReader plugInDefStream) { ChoGuard.ArgumentNotNullOrEmpty(plugInDefStream, "PlugInDefStream"); return(Load(plugInDefStream)); }
public ChoStringObjectFormattableAttribute(Type supportedType) { ChoGuard.ArgumentNotNullOrEmpty(supportedType, "SupportedType"); SupportedType = supportedType; }
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(); } }
protected override void Validate() { base.Validate(); ChoGuard.ArgumentNotNullOrEmpty(CodeSnippet, "CodeSnippet"); }
public ChoNameableObject(Type type) { ChoGuard.ArgumentNotNullOrEmpty(type, "Type"); Name = type.FullName; }
public ChoTypeAttribute(string typeName) { ChoGuard.ArgumentNotNullOrEmpty(typeName, "Type Name"); Type = ChoType.GetType(typeName); }
public ChoRegistrySectionAttribute1(string registryKey) { ChoGuard.ArgumentNotNullOrEmpty(registryKey, "RegistryKey"); _registryKey = registryKey; }