Пример #1
0
        public InsqlDescriptor ParseDescriptor(Stream insqlStream, string insqlNamespace)
        {
            using (insqlStream)
            {
                var doc = XDocument.Load(insqlStream);

                var root = doc.Root;

                if (root.Name != XName.Get("insql", insqlNamespace))
                {
                    return(null);
                }

                var typeAttr = root.Attribute(XName.Get("type", insqlNamespace));

                if (typeAttr == null)
                {
                    return(null);
                }

                var descriptor = new InsqlDescriptor(typeAttr.Value);

                foreach (var section in this.ParseSections(root))
                {
                    descriptor.Sections.Add(section.Id, section);
                }

                foreach (var map in this.ParseMapSections(root))
                {
                    descriptor.Maps.Add(map.Type, map);
                }

                return(descriptor);
            }
        }
        private InsqlDescriptor ParseDescriptor(Stream stream)
        {
            using (stream)
            {
                var doc = XDocument.Load(stream);

                var root = doc.Root;

                if (root.Name != XName.Get("insql", this.options.Value.Namespace))
                {
                    return(null);
                }

                var typeAttr = root.Attribute(XName.Get("type", this.options.Value.Namespace));

                if (typeAttr == null)
                {
                    return(null);
                }

                var type = Type.GetType(typeAttr.Value);

                if (type == null)
                {
                    throw new Exception($"insql type : {typeAttr.Value} not found !");
                }

                var descriptor = new InsqlDescriptor(type);

                foreach (var section in this.ParseSectionDescriptors(root))
                {
                    descriptor.Sections.Add(section.Id, section);
                }

                return(descriptor);
            }
        }
Пример #3
0
        public IInsqlSection Match(InsqlDescriptor insqlDescriptor, string dbType, string sqlId, IDictionary <string, object> sqlParam)
        {
            var optionsValue = this.options.Value;

            IInsqlSection insqlSection;

            if (optionsValue.CorssDbEnabled)
            {
                if (!string.IsNullOrWhiteSpace(dbType))
                {
                    if (insqlDescriptor.Sections.TryGetValue($"{sqlId}{optionsValue.CorssDbSeparator}{dbType}", out insqlSection))
                    {
                        return(insqlSection);
                    }
                }
            }

            if (insqlDescriptor.Sections.TryGetValue(sqlId, out insqlSection))
            {
                return(insqlSection);
            }

            return(null);
        }
Пример #4
0
        public IInsqlSection Match(InsqlDescriptor insqlDescriptor, string sqlId, IDictionary <string, object> sqlParam)
        {
            if (string.IsNullOrWhiteSpace(sqlId))
            {
                throw new ArgumentNullException(nameof(sqlId));
            }

            if (insqlDescriptor.Sections.TryGetValue(sqlId, out IInsqlSection insqlSection))
            {
                return(insqlSection);
            }

            var lastIndex = sqlId.LastIndexOf('.');

            if (lastIndex > -1)
            {
                if (insqlDescriptor.Sections.TryGetValue(sqlId.Substring(0, lastIndex), out insqlSection))
                {
                    return(insqlSection);
                }
            }

            return(null);
        }
Пример #5
0
 public void OnResolving(InsqlDescriptor insqlDescriptor, string dbType, string sqlId, IDictionary <string, object> sqlParam)
 {
 }