Esempio n. 1
0
 protected void AssignGroup(ref ZeusTemplateHeader header, string key, StringBuilder builder)
 {
     switch (key)
     {
     case ZeusConstants.Directives.COMMENTS_END:
         header.Comments = builder.ToString().TrimEnd();
         break;
     }
 }
		public ZeusTemplateHeader LoadTemplateHeaderStruct(string filePath)
		{
			ZeusTemplateHeader header = new ZeusTemplateHeader();
			try 
			{
				StreamReader reader = new StreamReader(filePath, true);
				LoadIntoTemplateHeader(reader, filePath, ref header);
				reader.Close();
			}
			catch (ZeusParseException ex)
			{
				header = new ZeusTemplateHeader();
				throw ex;
			}

			return header;
		}
Esempio n. 3
0
        public ZeusTemplateHeader LoadTemplateHeaderStruct(string filePath)
        {
            ZeusTemplateHeader header = new ZeusTemplateHeader();

            try
            {
                StreamReader reader = new StreamReader(filePath, true);
                LoadIntoTemplateHeader(reader, filePath, ref header);
                reader.Close();
            }
            catch (ZeusParseException ex)
            {
                header = new ZeusTemplateHeader();
                throw ex;
            }

            return(header);
        }
Esempio n. 4
0
        protected void AssignProperty(ref ZeusTemplateHeader header, string key, string val)
        {
            switch (key)
            {
            case ZeusConstants.Directives.UNIQUEID:
                header.UniqueID = val;
                break;

            case ZeusConstants.Directives.TITLE:
                header.Title = val;
                break;

            case ZeusConstants.Directives.NAMESPACE:
                header.Namespace = val;
                break;

            case ZeusConstants.Directives.SOURCE_TYPE:
                header.SourceType = val;
                break;
            }
        }
		public void LoadIntoTemplateHeader(StreamReader reader, string filepath, ref ZeusTemplateHeader header)
		{
			char[] whitespace = new char[4] {'\n', '\r', '\t', ' '};
			string key, val, line;
			int tagLength = ZeusConstants.START_DIRECTIVE.Length;
			int x, y;
			bool inGroupMode = false;
			string startGroupTag = string.Empty;
			StringBuilder builder = null;

			if (filepath != null) 
			{
				int lastIndex = filepath.LastIndexOf('\\');
				header.FileName = filepath.Substring(lastIndex + 1);
				header.FilePath = filepath.Substring(0, lastIndex + 1);
			}

			line = reader.ReadLine();
			while (line != null)
			{
				if (line.StartsWith(ZeusConstants.START_DIRECTIVE)) 
				{
					x = line.IndexOfAny(whitespace);
					if (x < 0) x = line.Length;
					y = x - tagLength;
				
					key = line.Substring(tagLength, y);

					if (!inGroupMode) 
					{
						if (IsGroupStartTag(key)) 
						{
							inGroupMode = true;
							startGroupTag = key;
							builder = new StringBuilder();
						}
						else 
						{
							val = line.Substring(x).Trim();
							AssignProperty(ref header, key, val);
						}
					}
					else 
					{
						if (IsGroupEndTag(key)) 
						{
							AssignGroup(ref header, key, builder);

							inGroupMode = false;
							startGroupTag = string.Empty;
						}
						else
						{
							//TODO: *** Could put a warning here. Possibly have a warnings collection. Maybe a CompileInfo class?
							builder.Append(line + "\r\n");
						}
					}
				}
				else if (inGroupMode)
				{
					builder.Append(line + "\r\n");
				}

				line = reader.ReadLine();
			}
		}
		protected void AssignProperty(ref ZeusTemplateHeader header, string key, string val) 
		{
			switch (key) 
			{
				case ZeusConstants.Directives.UNIQUEID:
					header.UniqueID = val;
					break;
				case ZeusConstants.Directives.TITLE:
					header.Title = val;
					break;
				case ZeusConstants.Directives.NAMESPACE:
					header.Namespace = val;
					break;
				case ZeusConstants.Directives.SOURCE_TYPE:
					header.SourceType = val;
					break;
			}
		}
		protected void AssignGroup(ref ZeusTemplateHeader header, string key, StringBuilder builder) 
		{
			switch (key) 
			{
				case ZeusConstants.Directives.COMMENTS_END:
					header.Comments = builder.ToString().TrimEnd();
					break;
			}
		}
		public TemplateTreeNode(ZeusTemplateHeader template)
		{
			//this.NodeFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold, GraphicsUnit.Point);
			this.ForeColor = Color.Blue;
			this.Text = template.Title;
			this.Tag = template.FilePath + template.FileName;
			this.Comments = template.Comments;
			this.UniqueId = template.UniqueID;
			this.Namespace = template.Namespace;
			this.IsLocked = !((template.SourceType == null) || (template.SourceType == ZeusConstants.SourceTypes.SOURCE));

			if (IsLocked) this.ImageIndex = this.SelectedImageIndex = 11;
			else this.ImageIndex = this.SelectedImageIndex = 6;
		}
Esempio n. 9
0
        public void LoadIntoTemplateHeader(StreamReader reader, string filepath, ref ZeusTemplateHeader header)
        {
            char[] whitespace = new char[4] {
                '\n', '\r', '\t', ' '
            };
            string        key, val, line;
            int           tagLength = ZeusConstants.START_DIRECTIVE.Length;
            int           x, y;
            bool          inGroupMode   = false;
            string        startGroupTag = string.Empty;
            StringBuilder builder       = null;

            if (filepath != null)
            {
                int lastIndex = filepath.LastIndexOf('\\');
                header.FileName = filepath.Substring(lastIndex + 1);
                header.FilePath = filepath.Substring(0, lastIndex + 1);
            }

            line = reader.ReadLine();
            while (line != null)
            {
                if (line.StartsWith(ZeusConstants.START_DIRECTIVE))
                {
                    x = line.IndexOfAny(whitespace);
                    if (x < 0)
                    {
                        x = line.Length;
                    }
                    y = x - tagLength;

                    key = line.Substring(tagLength, y);

                    if (!inGroupMode)
                    {
                        if (IsGroupStartTag(key))
                        {
                            inGroupMode   = true;
                            startGroupTag = key;
                            builder       = new StringBuilder();
                        }
                        else
                        {
                            val = line.Substring(x).Trim();
                            AssignProperty(ref header, key, val);
                        }
                    }
                    else
                    {
                        if (IsGroupEndTag(key))
                        {
                            AssignGroup(ref header, key, builder);

                            inGroupMode   = false;
                            startGroupTag = string.Empty;
                        }
                        else
                        {
                            //TODO: *** Could put a warning here. Possibly have a warnings collection. Maybe a CompileInfo class?
                            builder.Append(line + "\r\n");
                        }
                    }
                }
                else if (inGroupMode)
                {
                    builder.Append(line + "\r\n");
                }

                line = reader.ReadLine();
            }
        }