Exemplo n.º 1
0
 public virtual object LoadConfiguration(Type configType, string filename, ConfigFile parent)
 {
     ConfigFile configFile = null;
     TextReader textReader = null;
     filename = filename.Replace("$(AppDir)", PathHelper.AppDir);
     filename = filename.Replace("$(UserAppDir)", PathHelper.UserAppDir);
     filename = filename.Replace("$(BaseDir)", PathHelper.BaseDir);
     if (typeof(ConfigFile).IsAssignableFrom(configType))
     {
         if (File.Exists(filename + ".override"))
         {
             try
             {
                 String original = File.ReadAllText(filename);
                 String overriding = File.ReadAllText(filename + ".override");
                 String tabContent = overriding.Replace("\n", "\n\t\t\t");
                 Int32 indexStart = original.IndexOf(coloringStart);
                 Int32 indexEnd = original.IndexOf(coloringEnd);
                 String replaceTarget = original.Substring(indexStart, indexEnd - indexStart + coloringEnd.Length);
                 String finalContent = original.Replace(replaceTarget, tabContent);
                 File.WriteAllText(filename, finalContent);
                 File.Delete(filename + ".override");
             }
             catch { /* NO ERRORS... */ }
         }
         textReader = new StreamReader(filename);
         configFile = Deserialize(textReader, configType) as ConfigFile;
         configFile.filename = filename;
         configFile.init(this, parent);
     }
     return configFile;
 }
Exemplo n.º 2
0
 public virtual void addIncludedFile(ConfigFile file)
 {
     ConfigFile[] configFiles = null;
     configFiles = new ConfigFile[includedFiles.Length + 1];
     includedFiles.CopyTo(configFiles, 0);
     configFiles[includedFiles.Length] = file;
     includedFiles = configFiles;
 }
Exemplo n.º 3
0
        protected virtual byte[] LoadFile(string filename, ConfigFile parent)
        {
			System.IO.Stream res;
			byte[] buf;
			res = OpenFile(filename, parent);
			if (res != null)
			{
				buf = new byte[res.Length];
				res.Read(buf ,0 ,buf.Length);
				return buf;
			}
			return null;
		}
Exemplo n.º 4
0
 public override void init(ConfigurationUtility utility, ConfigFile theParent)
 {
     ConfigFile configFile = null;
     includedFiles = new ConfigFile[0];
     base.init(utility, theParent);
     if (includes == null) includes = new include[0];
     for (int j = 0; j<includes.Length; j++) includes[j].init(utility, _parent);
     for (int i = 0; i<includes.Length; i++)
     {
         configFile = (ConfigFile)utility.LoadConfiguration(base.GetType(), includes[i].file, (ConfigFile)_parent);
         addIncludedFile(configFile);
     }
     CollectScintillaNodes(null);
 }
Exemplo n.º 5
0
        protected virtual Stream OpenFile(string filename, ConfigFile parent)
        {
			Stream res;
            filename = filename.Replace("$(AppDir)", PathHelper.AppDir);
            filename = filename.Replace("$(UserAppDir)", PathHelper.UserAppDir);
            filename = filename.Replace("$(BaseDir)", PathHelper.BaseDir);
            if (File.Exists(filename)) res = new FileStream(filename, FileMode.Open, FileAccess.Read);
			else res = _assembly.GetManifestResourceStream(String.Format( "{0}.{1}" , _assembly.GetName().Name, filename.Replace("\\" , "." )));
			if (res == null && parent != null && parent.filename != null)
			{
				int p = parent.filename.LastIndexOf('\\');
				if (p > 0) return OpenFile(String.Format( "{0}\\{1}", parent.filename.Substring(0, p), filename), null);
			}
			return res;
		}
Exemplo n.º 6
0
        public override void init(ConfigurationUtility utility, ConfigFile theParent)
        {
            base.init(utility, theParent);
            if (usekeywords == null) usekeywords = new UseKeyword[0];
            if (usestyles == null) usestyles = new UseStyle[0];
            for (int j = 0; j<usekeywords.Length; j++)
            {
                usekeywords[j].init(utility, _parent);
            }
            for (int i = 0; i<usestyles.Length; i++)
            {
                usestyles[i].init(utility, _parent);
            }
            if (lexer != null) lexer.init(utility, _parent);
			if (characterclass != null) characterclass.init(utility, _parent);
			if (editorstyle != null) editorstyle.init(utility, _parent);
        }
Exemplo n.º 7
0
 public virtual object LoadConfiguration(Type configType, string filename, ConfigFile parent)
 {
     ConfigFile configFile = null;
     Stream stream = null;
     TextReader textReader = null;
     configFile = null;
     if (typeof(ConfigFile).IsAssignableFrom(configType))
     {
         stream = OpenFile(filename, parent);
         if (stream != null)
         {
             textReader = new StreamReader(stream);
             configFile = Deserialize(textReader, configType) as ConfigFile;
             configFile.filename = filename;
             configFile.init(this, parent);
         }
     }
     return configFile;
 }
Exemplo n.º 8
0
        protected virtual Stream OpenFile(string filename, ConfigFile parent)
        {
			System.IO.Stream res;
			string appPath = Path.GetDirectoryName(Application.ExecutablePath);
			string appDir = Regex.Replace(filename, "@APPDIR", appPath);
			if (System.IO.File.Exists(appDir))
			{
				res = new System.IO.FileStream(appDir, System.IO.FileMode.Open);
			}
			else
			{
				res = _assembly.GetManifestResourceStream(String.Format( "{0}.{1}" , _assembly.GetName().Name, filename.Replace("\\" , "." )));
			}
			if (res == null && parent != null && parent.filename != null)
			{
				int p = parent.filename.LastIndexOf('\\');
				if (p > 0) return OpenFile(String.Format( "{0}\\{1}", parent.filename.Substring(0, p), filename), null);
			}
			return res;
		}
Exemplo n.º 9
0
 public virtual object LoadConfiguration(Type configType, ConfigFile parent)
 {
     return LoadConfiguration(configType, "ScintillaNET.xml", parent);
 }
Exemplo n.º 10
0
 public virtual object LoadConfiguration(string filename, ConfigFile parent)
 {
     return LoadConfiguration(typeof(Scintilla), filename, parent);
 }
Exemplo n.º 11
0
 public virtual object LoadConfiguration(ConfigFile parent)
 {
     return LoadConfiguration(typeof(Scintilla), "ScintillaNET.xml", parent);
 }
Exemplo n.º 12
0
 public override void init(ConfigurationUtility utility, ConfigFile theParent)
 {
     base.init(utility, theParent);
     if (languages == null) languages = new Language[0];
     if (styleclasses == null)  styleclasses = new StyleClass[0];
     if (keywordclass == null) keywordclass = new KeywordClass[0];
     if (globals == null) globals = new Value[0];
     for (int i2 = 0; i2<languages.Length; i2++)
     {
         languages[i2].init(utility, _parent);
     }
     for (int k = 0; k<styleclasses.Length; k++)
     {
         styleclasses[k].init(utility, _parent);
     }
     for (int j = 0; j<keywordclass.Length; j++)
     {
         keywordclass[j].init(utility, _parent);
     }
     for (int i1 = 0; i1<globals.Length; i1++)
     {
         globals[i1].init(utility, _parent);
     }
     if (characterclasses == null) characterclasses = new CharacterClass[0];
     for (int k = 0; k<characterclasses.Length; k++)
     {
         characterclasses[k].init(utility, _parent);
     }
 }
Exemplo n.º 13
0
 public override void init(ConfigurationUtility utility, ConfigFile theParent)
 {
     base.init(utility, theParent);
     if (!string.IsNullOrEmpty(cls)) inheritstyle = cls;
 }
Exemplo n.º 14
0
 public override void init(ConfigurationUtility utility, ConfigFile theParent)
 {
     base.init(utility, theParent);
     if (cls != null && cls.Length > 0) inheritstyle = cls;
 }
Exemplo n.º 15
0
 public virtual void init(ConfigurationUtility utility, ConfigFile theParent)
 {
     if (theParent == null) _parent = (ConfigFile)this;
     else _parent = theParent;
 }