Example #1
0
        private IVbModule AnalyzeElement(ElementBase element)
        {
            try
            {
                using (Stream stream = _fileReader.Read(element, _project))
                {
                    VbPartitionedFile content = _fileReader.ReadPartitionedFile(element, stream);

                    return ModuleReflector.GetReflectedModule(content);
                }
            }
            catch (Exception)
            {

            }

            return null;
        }
Example #2
0
        string IVbElementSerializer.Serialize(ElementBase element)
        {
            string key = "";
            string value = "";

            switch (element.GetType().Name)
            {
                case "ReferenceElement":
                    key = "Reference";
                    value = _referenceParser.Parse((ReferenceElement)element);
                    break;
                case "ObjectElement":
                    key = "Object";
                    value = ParseObject(element);
                    break;
                case "ModuleElement":
                    key = "Module";
                    value = ParseGeneric(element);
                    break;
                case "ClassElement":
                    key = "Class";
                    value = ParseGeneric(element);
                    break;
                case "FormElement":
                    key = "Form";
                    value = ParseFormOrUserControl(element);
                    break;
                case "UserControlElement":
                    key = "UserControl";
                    value = ParseFormOrUserControl(element);
                    break;
                default:
                    throw new NotSupportedException(string.Format("Element '{0}' is not supported!", element.GetType().Name));
            }

            return string.Format("{0}={1}", key, value);
        }
Example #3
0
 void IVbFileWriter.Write(ElementBase element, IVbProject parentProject, Stream stream)
 {
     throw new NotImplementedException("Not implemented... yet!");
 }
Example #4
0
        private void ExtendNode(ElementBase item, TreeNode itemNode)
        {
            if (item is ClassElement || item is ModuleElement || item is FormElement)
            {
                IVbModule reflectedModule = AnalyzeElement(item);
                if (reflectedModule == null)
                {
                    return;
                }

                foreach (IVbMember member in reflectedModule.Members)
                {
                    TreeNode node = new TreeNode();
                    node.Tag = member;

                    if (member is IVbAttribute)
                    {
                        node.Text = string.Format("(A) {0}", ((IVbAttribute)member).Name);
                    }
                    else if (member is IVbProperty)
                    {
                        IVbProperty property = (IVbProperty)member;
                        node.Text = string.Format("(P) {0} {1}", property.Accessor, property.Name);
                    }
                    else if (member is IVbMethod)
                    {
                        node.Text = string.Format("(M) {0}", ((IVbMethod)member).Name);
                    }
                    else if (member is IVbField)
                    {
                        node.Text = string.Format("(F) {0}", ((IVbField)member).Name);
                    }

                    itemNode.Nodes.Add(node);
                }
            }
        }
Example #5
0
        private string ParseObject(ElementBase element)
        {
            ObjectElement obj = (ObjectElement)element;

            string r = "{" + obj.Guid.ToString() + "}";
            r += "#" + obj.Version;
            r += "#";
            if (obj.Reserved != null)
            {
                r += obj.Reserved;
            }
            r += obj.Name;

            return r;
        }
Example #6
0
 private string ParseGeneric(ElementBase element)
 {
     return string.Format("{0}; {1}", element.Name, element.FileName);
 }
Example #7
0
        private void ParseGeneric(ElementBase fileBase, string value)
        {
            string[] parts = value.Split(';');

            fileBase.Name = parts[0].Trim();

            if (parts.Length == 2)
            {
                fileBase.FileName = parts[1].Trim();
            }
        }
Example #8
0
 private string ParseFormOrUserControl(ElementBase element)
 {
     return element.FileName;
 }
Example #9
0
 VbPartitionedFile IVbFileReader.ReadPartitionedFile(ElementBase element, Stream stream)
 {
     StreamReader reader = new StreamReader(stream, Encoding.Default);
     return VbPartitionedFile.GetPartitionedFile(reader.ReadToEnd());
 }
Example #10
0
 Stream IVbFileReader.Read(ElementBase element, IVbProject parentProject)
 {
     return File.OpenRead(element.GetAbsoluteFileName(parentProject));
 }