예제 #1
0
        public static IALObject CreateInstance(ALObjectType type)
        {
            var     items    = new ALObjectTypeMap();
            dynamic instance = Activator.CreateInstance(items[type]);

            return(instance);
        }
예제 #2
0
        /// <summary>
        /// Basic object information, such as Type, ID, Name
        /// </summary>
        /// <param name="Lines">Array of textlines</param>
        /// <param name="Target">Current ALObject instance</param>
        public void GetObjectInfo(string line, out IALObject Target)
        {
            Target = new ALObject();

            if (!string.IsNullOrEmpty(line))
            {
                var items = Regex.Match(line, ObjectHeaderPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                var type  = items.Groups[1].Value.ToEnum <ALObjectType>();
                var idTxt = items.Groups[2].Value;

                Target    = ALObjectTypeMap.CreateInstance(type);
                Target.Id = 0;
                if (!String.IsNullOrEmpty(idTxt))
                {
                    Target.Id = int.Parse(items.Groups[2].Value);
                }
                var nameParts = items.Groups[3].Value.Split(" extends ");
                if (nameParts.Length < 2)
                {
                    nameParts = items.Groups[3].Value.Split(" implements ");
                }
                Target.Name = nameParts[0].Replace("\"", "").Trim();
                Target.Type = type;
            }

            OnGetObjectInfo(line, Target);
        }