Exemplo n.º 1
0
 public graphNode(dependency obj = default, nodeSet pred = default, nodeSet succ = default, long index = default, long ndeps = default)
 {
     this.obj   = obj;
     this.pred  = pred;
     this.succ  = succ;
     this.index = index;
     this.ndeps = ndeps;
 }
            public static string JsonToXmlString(dependency obj)
            {
                XmlDocument   document = new XmlDocument();
                StringBuilder sb = new StringBuilder(); string serialized = string.Empty;

                using (TextWriter tw = new StringWriter(sb))
                {
                    var xmlS = new XmlSerializer(typeof(dependency));
                    xmlS.Serialize(tw, obj);
                    serialized = sb.ToString();
                    serialized = serialized.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n", "");
                    serialized = serialized.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ", "");
                    serialized = serialized.Replace("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
                }

                return(serialized.ToString());
            }
Exemplo n.º 3
0
 _serializer = new FileCacheInfoSerializer(dependency, _fileInfoCache);
Typically when the (more modern of the) systems I work on are implementing this data layer pattern, such as some Reader, they will take a db context via constructor parameter (dependency injection) and keep it for the life of the class, rather than each method making their own context in a using
        private void richTextBox1_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                int    begin     = richTextBox1.GetFirstCharIndexOfCurrentLine();
                string endString = richTextBox1.Text.Substring(begin);
                string text      = endString;
                int    rtIndex   = endString.IndexOf("\n");

                if (rtIndex == -1)
                {
                    rtIndex = endString.Length;
                }
                else
                {
                    text = endString.Substring(0, rtIndex);
                }

                richTextBox1.SelectionStart  = begin;
                richTextBox1.SelectionLength = rtIndex;

                DirectoryInfo info = new DirectoryInfo(text);
                text = info.Parent.FullName;
                if (!Directory.Exists(text))
                {
                    return;
                }


                string   str  = text.Replace(mavenHomeDirText.Text, "");
                string[] strs = str.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);


                if (strs.Length < 3)
                {
                    return;
                }

                int    len        = strs.Length;
                string groupId    = strs[0];
                string artifactId = strs[len - 2];
                string version    = strs[len - 1];

                if ("0123456789".IndexOf(version[0].ToString()) == -1)
                {
                    BindRichBox(richTextBox3, "所选jar不符合规则", false);
                    return;
                }
                for (int i = 1; i < len - 2; i++)
                {
                    groupId += "." + strs[i];
                }

                dependency dy = new dependency();
                dy.groupId    = groupId;
                dy.artifactId = artifactId;
                dy.version    = version;
                string xml = dependency.JsonToXmlString(dy);

                BindRichBox(richTextBox3, xml, false);
            }
            catch
            {
            }
        }