コード例 #1
0
        public IEnumerable <string> GetPossibleTablesForAlias(string alias)
        {
            HashSet <string> result = new HashSet <string>();

            foreach (string t in proposedAliases.Keys)
            {
                if (proposedAliases[t] == alias)
                {
                    result.AddIfNotExists(t);
                }
            }

            if (result.Count == 0)
            {
                foreach (DbTable t in tables.Values)
                {
                    if (t.name.StartsWith(alias) && t.GetAlias(false) == alias)
                    {
                        result.AddIfNotExists(t.name);
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        public void AliasUsed(string alias, string table)
        {
            DbTable t = tables[table];

            tablesByAlias.AddIfNotExists(alias, t);
            tablesByAlias.SetPosition(alias, t.AliasUsed(alias));
            activeTables.AddIfNotExists(t);
        }
コード例 #3
0
 public override void OnNodesRemoved(ITabularObject parent, params ITabularObject[] children)
 {
     if (UpdateLocks > 0)
     {
         structureChangedItems.AddIfNotExists(parent);
         return;
     }
     else
     {
         NodesRemoved?.Invoke(this, new TreeModelEventArgs(GetPath(parent), children));
     }
 }
コード例 #4
0
ファイル: Parse.cs プロジェクト: fence-post/plants
        public void ParsePlant(string url)
        {
            string type = urls[url];

            content.Clear();
            content.Add("plantType", type);

            var web = new HtmlWeb();
            var doc = web.Load(url);

            var articles = doc.DocumentNode.SelectNodes("//div[contains(@class,'main')]"); // /@id=dvResults/div

            GetSet(articles.First(), "image", ".//ul[@id='image_tabs']/li", ".//img/@src");
            GetSet(articles.First(), "habitat", ".//dl/dt[contains(text(), 'Habitat:')]/following-sibling::dd[1]/a", ".//text()");
            GetPart(articles.First(), "habDescription", ".//dl/dt[contains(text(), 'Habitat:')]/following::dd/text()");
            GetSet(articles.First(), "shadePreference", ".//div[@class='shade-preference']/img", ".//@title");
            GetPart(articles.First(), "specialUses", ".//dl/dt[contains(text(), 'Special Uses:')]/following::dd/text()");
            GetPart(articles.First(), "soilTolerance", ".//dl/dt[contains(text(), 'Soil Tolerance:')]/following::dd/text()");
            GetPart(articles.First(), "matureHeight", ".//dl/dt[contains(text(), 'Mature Height:')]/following::dd/text()");
            GetPart(articles.First(), "description", ".//p");
            GetPart(articles.First(), "commonName", ".//h1");
            GetPart(articles.First(), "scientificName", ".//h2[@class='scientific']");

            soils.AddIfNotExists(Content("soilTolerance"));
        }
コード例 #5
0
        public void AddTablesByAffinity()
        {
            HashSet <DbTable> list = new HashSet <DbTable>();

            if (parent.parentQuery.select != null)
            {
                foreach (Column c in parent.parentQuery.select.columns.tokens)
                {
                    if (c.dbColumn != null)
                    {
                        list.AddIfNotExists(c.dbColumn.table);
                    }
                }
            }
            List <DbTable> result = new List <DbTable>();

            if (parent.parentQuery.from != null)
            {
                foreach (Table t in parent.parentQuery.from.tables.tokens)
                {
                    if (t.dbTable != null && t.dbTable.tablePaths != null)
                    {
                        foreach (DbTable table in t.dbTable.tablePaths.accessibleTables)
                        {
                            list.AddIfNotExists(table);
                        }
                    }
                }
                foreach (DbTable t in list)
                {
                    if (parent.parentQuery.from.tables.GetTableByName(t.name) == null)
                    {
                        result.Add(t);
                    }
                }
            }
            else
            {
                result.AddRange(list);
            }
            foreach (DbTable t in list)
            {
                AddTable(t.name);
            }
        }
コード例 #6
0
ファイル: Parse.cs プロジェクト: fence-post/plants
        List <string> GetPlantUses(string spacialUses)
        {
            spacialUses = spacialUses.ToLower();

            HashSet <string> result     = new HashSet <string>();
            string           insectName = "Bees, Butterflies, Pollinators";

            if (spacialUses.Contains("insects"))
            {
                result.AddIfNotExists(insectName);
            }
            if (spacialUses.Contains("bees"))
            {
                result.AddIfNotExists(insectName);
            }
            if (spacialUses.Contains("butterflies"))
            {
                result.AddIfNotExists(insectName);
            }
            if (spacialUses.Contains("pollinators"))
            {
                result.AddIfNotExists(insectName);
            }

            if (spacialUses.Contains("hummingbirds"))
            {
                result.AddIfNotExists("Birds");
            }
            if (spacialUses.Contains("birds"))
            {
                result.AddIfNotExists("Birds");
            }

            if (spacialUses.Contains("drought tolerant"))
            {
                result.AddIfNotExists("Drought Tolerant");
            }

            if (spacialUses.Contains("deer resistant"))
            {
                result.AddIfNotExists("Deer Resistant");
            }

            if (spacialUses.Contains("bank stabilization"))
            {
                result.AddIfNotExists("Bank Stabilization");
            }

            return(result.ToList());
        }
コード例 #7
0
        internal static string GenerateInspectedReferences(this FilesOperations fileOps, Type element,
                                                           HashSet <Type> alltypes)
        {
            var inspectedTypes = InspectReferences(element, alltypes);
            var references     = new HashSet <string>();
            var types          = ConfigurationRepository.Instance.ReferencesForType(element);

            if (types != null)
            {
                foreach (var attr in types)
                {
                    if (attr.Type != element)
                    {
                        var path = attr.Type != null?fileOps.GetRelativePathForType(attr.Type, element) : attr.RawPath;

                        if (!string.IsNullOrEmpty(path))
                        {
                            references.AddIfNotExists(path);
                        }
                    }
                }
            }
            foreach (var inspectedType in inspectedTypes)
            {
                if (inspectedType != element)
                {
                    var path = fileOps.GetRelativePathForType(inspectedType, element);
                    if (!string.IsNullOrEmpty(path))
                    {
                        references.AddIfNotExists(path);
                    }
                }
            }
            var sb = new StringBuilder();

            foreach (var reference in references)
            {
                if (!string.IsNullOrEmpty(reference))
                {
                    sb.AppendLine(string.Format("/// <reference path=\"{0}\"/>", reference));
                }
            }

            return(sb.ToString().Trim());
        }
コード例 #8
0
        void AddMemberToTarget(Member member, DataType parentDataType, HashSet <DocumentViewModel> target)
        {
            // If this is some kind of overridden member, try to resolve the original declaration as it's the one that's
            // interesting to us
            member = ResolveOriginalDeclaration(member);

            // NOTE: Instead of just using GetUri and GetId directly on the entity to generate the ID, we use the
            // signature variants of the uri/id methods instead and prefix it with the uri and id of the containing
            // data type.
            //
            // This is done to properly support flattening inherited members into the data exchange format used by the
            // compiler backend; while the ToString() method on a type that inherits from Uno.Object without overriding
            // ToString() directly will have the ToString() method listed when using the EnumerateFlattenedMethods()
            // extension method, that method will still belong to Uno.Object and not the type that inherited the method.
            //
            // The data structure requires the type to own its own inherited methods, hence we do it like this.
            var id  = parentDataType.GetUri() + "/" + member.GetUriSignature();
            var uri = GetMemberUri(member, parentDataType);

            var comment = _commentParser.Read(member);
            var ns      = parentDataType.FindNamespace();
            var titles  = new TitlesViewModel(Naming.GetPageTitle(member),
                                              Naming.GetIndexTitle(member),
                                              Naming.GetFullIndexTitle(member),
                                              Naming.GetNavigationTitle(member),
                                              member.FullName);
            var syntax       = new SyntaxViewModel(Syntax.BuildUnoSyntax(member, parentDataType), Syntax.BuildUxSyntax(member));
            var location     = new LocationViewModel(ns.FullName, ns.GetUri(), member.Source.Package.Name, member.Source.Package.Version);
            var declaredIn   = new DataTypeBuilder(Naming, Syntax, Exportable, AttachedMembers, _commentParser).BuildReference(member.DeclaringType);
            var parameters   = GetParameters(member);
            var returns      = GetReturns(member);
            var uxProperties = GetUxProperties(member);
            var values       = BuildValues(member);
            var flags        = BuildFlags(member);
            var attributes   = BuildAttributes(member);

            var type      = GetTypeName(member, comment, uxProperties);
            var isVirtual = uri == null;

            var viewModel = new MemberViewModel(new DocumentIdViewModel(id, parentDataType.GetUri(), type, member.GetModifierNames()),
                                                new DocumentUriViewModel(id, member.GetUri(), isVirtual),
                                                titles,
                                                syntax,
                                                location,
                                                declaredIn,
                                                parameters,
                                                returns,
                                                uxProperties,
                                                values,
                                                flags,
                                                new CommentViewModel(comment),
                                                attributes,
                                                member);

            target.AddIfNotExists(viewModel);
        }
コード例 #9
0
 public override void OnStructureChanged(ITabularNamedObject obj = null)
 {
     if (UpdateLocks > 0)
     {
         structureChangedItems.AddIfNotExists(obj);
         return;
     }
     else
     {
         if (obj == null)
         {
             OnStructureChanged(new TreePath());
         }
         else
         {
             OnStructureChanged(GetPath(obj));
         }
     }
 }
コード例 #10
0
ファイル: DataTypeBuilder.cs プロジェクト: ichan-mb/uno
        private void AddDataTypeToTarget(DataType dataType, DataType swizzlerParent, HashSet <DocumentViewModel> target)
        {
            var ns                    = dataType.FindNamespace();
            var titles                = BuildDataTypeTitles(dataType);
            var syntax                = new SyntaxViewModel(Syntax.BuildUnoSyntax(dataType), Syntax.BuildUxSyntax(dataType));
            var baseType              = BuildBaseType(dataType);
            var location              = new LocationViewModel(ns.FullName, ns.GetUri(), dataType.Source.Package.Name, dataType.Source.Package.Version);
            var uxProperties          = BuildUxProperties(dataType);
            var inheritance           = GetInheritance(dataType);
            var parameters            = GetParameters(dataType);
            var returns               = BuildReturns(dataType);
            var values                = BuildValues(dataType);
            var implementedInterfaces = BuildImplementedInterfaces(dataType);
            var attributes            = BuildAttributes(dataType);

            DocumentViewModel viewModel;

            if (swizzlerParent == null)
            {
                var comment = _commentParser.Read(dataType);
                var type    = GetTypeName(dataType, comment);

                var nsRef = new NamespaceBuilder(Naming, Syntax, Exportable, AttachedMembers, _commentParser).BuildReference(ns);
                viewModel = new DataTypeViewModel(new DocumentIdViewModel(dataType.GetUri(),
                                                                          dataType.Parent.GetUri(),
                                                                          type,
                                                                          dataType.GetModifierNames()),
                                                  new DocumentUriViewModel(dataType.GetUri(), dataType.GetUri(), false),
                                                  titles,
                                                  syntax,
                                                  baseType,
                                                  location,
                                                  inheritance,
                                                  parameters,
                                                  returns,
                                                  uxProperties,
                                                  values,
                                                  new CommentViewModel(comment),
                                                  nsRef,
                                                  implementedInterfaces,
                                                  attributes,
                                                  dataType);
            }
            else
            {
                var uri = swizzlerParent.GetUri() + "/" + dataType.GetUri().Replace("/", "_");
                viewModel = new SwizzlerTypeViewModel(new DocumentIdViewModel(uri, swizzlerParent.GetUri(), "SwizzlerType", dataType.GetModifierNames()),
                                                      new DocumentUriViewModel(uri, dataType.GetUri(), false),
                                                      titles,
                                                      null);
            }
            target.AddIfNotExists(viewModel);
        }
コード例 #11
0
        /// <summary>
        /// Constructs new inspected references set
        /// </summary>
        /// <param name="references">References</param>
        /// <param name="imports">Imports</param>
        public InspectedReferences(IEnumerable <RtReference> references, IEnumerable <RtImport> imports = null)
        {
            foreach (var rtReference in references)
            {
                _references.AddIfNotExists(rtReference);
            }

            if (imports != null)
            {
                foreach (var rtImport in imports.Where(c => c.IsWildcard))
                {
                    _imports.AddIfNotExists(rtImport);
                    _starImportsAs[rtImport.From] = rtImport;
                }

                foreach (var rtImport in imports.Where(c => !c.IsWildcard))
                {
                    _imports.AddIfNotExists(rtImport);
                }
            }
        }
コード例 #12
0
        void AddAttachedMemberToTarget(string name, MemberType memberType, Method underlyingMethod, DataType returnType, DataType parentDataType, HashSet <DocumentViewModel> target)
        {
            var uxAttribute = underlyingMethod.Attributes.SingleOrDefault(e => e.ReturnType.QualifiedName == ExportConstants.UxAttachedPropertySetterAttributeName ||
                                                                          e.ReturnType.QualifiedName == ExportConstants.UxAttachedEventAdderAttributeName);

            if (uxAttribute == null)
            {
                throw new ArgumentException($"UX attached attribute not found on {underlyingMethod.UnoName}");
            }

            var uxAttributeName = uxAttribute.Arguments.Length == 0 ? null : uxAttribute.Arguments[0].ConstantString;

            if (string.IsNullOrWhiteSpace(uxAttributeName))
            {
                throw new ArgumentException($"UX attached attribute did not contain any on {underlyingMethod.UnoName}");
            }
            uxAttributeName = uxAttributeName.ToLowerInvariant()
                              .Replace(".", "_");

            var id     = parentDataType.GetUri() + "/" + uxAttributeName + "_" + underlyingMethod.GetUriSignature();
            var titles = new TitlesViewModel(Naming.GetPageTitle(underlyingMethod),
                                             uxAttribute.Arguments[0].ConstantString,
                                             uxAttribute.Arguments[0].ConstantString,
                                             Naming.GetNavigationTitle(underlyingMethod),
                                             Naming.GetFullIndexTitle(underlyingMethod));
            var declaredIn = new DataTypeBuilder(Naming, Syntax, Exportable, AttachedMembers, _commentParser).BuildReference(underlyingMethod.DeclaringType);
            var parameters = GetParameters(underlyingMethod);
            var returns    = GetReturns(underlyingMethod, returnType);
            var values     = BuildValues(returnType);
            var source     = new AttachedMemberSourceViewModel(underlyingMethod.DeclaringType.GetUri(), Naming.GetIndexTitle(underlyingMethod.DeclaringType));
            var comment    = _commentParser.Read(underlyingMethod);

            if (!Exportable.IsExportableAndVisible(underlyingMethod.DeclaringType))
            {
                throw new Exception($"Found attached UX member {underlyingMethod.FullName} declared inside non-exportable class {underlyingMethod.DeclaringType.FullName}");
            }

            var viewModel = new AttachedMemberViewModel(new DocumentIdViewModel(id, parentDataType.GetUri(), "AttachedUx" + memberType.ToString("G"), new List <string>()),
                                                        new DocumentUriViewModel(id, underlyingMethod.GetUri(), true),
                                                        titles,
                                                        declaredIn,
                                                        parameters,
                                                        returns,
                                                        values,
                                                        source,
                                                        new CommentViewModel(comment),
                                                        underlyingMethod);

            target.AddIfNotExists(viewModel);
        }
コード例 #13
0
 private static void InspectTypeReferences(Type argument, HashSet <Type> alltypes, HashSet <Type> referenceContainer)
 {
     if (alltypes.Contains(argument))
     {
         referenceContainer.AddIfNotExists(argument);
     }
     if (argument._IsGenericType())
     {
         var args = argument._GetGenericArguments();
         foreach (var type in args)
         {
             InspectTypeReferences(type, alltypes, referenceContainer);
         }
     }
 }
コード例 #14
0
ファイル: Extensions.cs プロジェクト: kindex/labyrinth2
        public Extensions()
        {
            HashSet<string> ext = new HashSet<string>();

            Array.ForEach<string>(
                GL.GetString(StringName.Extensions).Split(' '),
                (string extension) => { if (extension.Length > 0) ext.AddIfNotExists(extension); }
            );

            PropertyInfo[] properties = typeof(Extensions).GetProperties();
            foreach (PropertyInfo property in properties)
            {
                property.SetValue(this, ext.Contains("GL_" + property.Name), null);
            }
        }
コード例 #15
0
ファイル: DbTable.cs プロジェクト: fence-post/sqrach
        public void AnalyzeAffinities()
        {
            Dictionary <DbColumn, double> label       = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> identifier  = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> descriptive = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> when        = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> category    = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> location    = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> quantity    = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> selecty     = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> groupy      = new Dictionary <DbColumn, double>();
            Dictionary <DbColumn, double> ordery      = new Dictionary <DbColumn, double>();

            if (name == "categories")
            {
                int nn = 0;
            }

            HashSet <DbTable> tables = new HashSet <DbTable>();

            // tables.AddRange(tablePaths.accessibleTables);
            tables.AddIfNotExists(this);

            foreach (DbTable t in tables)
            {
                t.GetTopColumnsByAffinity("label", label, this);
                t.GetTopColumnsByAffinity("identifier", identifier, this);
                t.GetTopColumnsByAffinity("descriptive", descriptive, this);
                t.GetTopColumnsByAffinity("when", when, this);
                t.GetTopColumnsByAffinity("category", category, this);
                t.GetTopColumnsByAffinity("location", location, this);
                t.GetTopColumnsByAffinity("selecty", selecty, this);
                t.GetTopColumnsByAffinity("groupy", groupy, this);
                t.GetTopColumnsByAffinity("ordery", ordery, this);
                t.GetTopColumnsByAffinity("quantity", quantity, this);
            }

            queryColumns.Add("label", GetTopColumns("label", label));
            queryColumns.Add("identifier", GetTopColumns("identifier", identifier));
            queryColumns.Add("descriptive", GetTopColumns("descriptive", descriptive));
            queryColumns.Add("when", GetTopColumns("when", when));
            queryColumns.Add("category", GetTopColumns("category", category));
            queryColumns.Add("location", GetTopColumns("location", location));
            queryColumns.Add("selecty", GetTopColumns("selecty", selecty));
            queryColumns.Add("groupy", GetTopColumns("groupy", groupy));
            queryColumns.Add("ordery", GetTopColumns("ordery", ordery));
            queryColumns.Add("quantity", GetTopColumns("quantity", quantity));
        }
コード例 #16
0
        void AddNamespaceToTarget(Namespace ns, HashSet <DocumentViewModel> target)
        {
            var titles = new TitlesViewModel(Naming.GetPageTitle(ns),
                                             Naming.GetIndexTitle(ns),
                                             Naming.GetFullIndexTitle(ns),
                                             Naming.GetNavigationTitle(ns),
                                             ns.QualifiedName);
            var syntax    = new SyntaxViewModel(Syntax.BuildUnoSyntax(ns), Syntax.BuildUxSyntax(ns));
            var parentUri = ns.ParentNamespace == null || ns.ParentNamespace.Name == ExportConstants.RootNamespaceName ? null : ns.ParentNamespace.GetUri();

            target.AddIfNotExists(new NamespaceViewModel(new DocumentIdViewModel(ns.GetUri(), parentUri, "Namespace", new List <string>()),
                                                         new DocumentUriViewModel(ns.GetUri(), ns.GetUri(), false),
                                                         titles,
                                                         syntax,
                                                         null));
        }
コード例 #17
0
ファイル: Parse.cs プロジェクト: fence-post/plants
        List <string> GetSoilPreferences(string pref)
        {
            pref = pref.ToLower();

            HashSet <string> result = new HashSet <string>();

            if (pref.Contains("moist"))
            {
                result.AddIfNotExists("Moist");
            }
            if (pref.Contains("dry"))
            {
                result.AddIfNotExists("Dry");
            }
            if (pref.Contains("rich"))
            {
                result.AddIfNotExists("Rich");
            }
            if (pref.Contains("acidic"))
            {
                result.AddIfNotExists("Acidic");
            }
            if (pref.Contains("drained"))
            {
                result.AddIfNotExists("Well Drained");
            }
            if (pref.Contains("good drainage"))
            {
                result.AddIfNotExists("Well Drained");
            }
            if (pref.Contains("rocky"))
            {
                result.AddIfNotExists("Rocky");
            }
            if (pref.Contains("drought"))
            {
                result.AddIfNotExists("Drought Tolerant");
            }

            return(result.ToList());
        }
コード例 #18
0
 private void ExportReferences(TextWriter tw, IEnumerable <Type> types = null)
 {
     WriteWarning(tw);
     tw.WriteLine(_referenceBuilder.ToString());
     if (types != null)
     {
         HashSet <string> pathes = new HashSet <string>();
         foreach (var type in types)
         {
             var inspected = _fileOps.GenerateInspectedReferences(type, _allTypesHash);
             if (!string.IsNullOrEmpty(inspected) && !string.IsNullOrWhiteSpace(inspected))
             {
                 pathes.AddIfNotExists(inspected);
             }
         }
         foreach (var path in pathes)
         {
             tw.WriteLine(path);
         }
     }
 }
コード例 #19
0
ファイル: TokenList.cs プロジェクト: fence-post/sqrach
 public int Add(Column c)
 {
     tableAliases.AddIfNotExists(c.tableAlias);
     return(_Add(c as Column));
 }
コード例 #20
0
 public void ColumnUsed(DbColumn col)
 {
     activeColumns.AddIfNotExists(col);
     col.table.columns.SetPosition(col.name, col.Used());
 }
コード例 #21
0
 public void Hide(Control c)
 {
     c.Visible = false;
     hiddenControls.AddIfNotExists(c);
 }
コード例 #22
0
        private void ExportReferences(TextWriter tw, IEnumerable<Type> types = null)
        {
            WriteWarning(tw);
            tw.WriteLine(_referenceBuilder.ToString());
            if (types != null)
            {
                HashSet<string> pathes = new HashSet<string>();
                foreach (var type in types)
                {
                    var inspected = _fileOps.GenerateInspectedReferences(type, _allTypesHash);
                    if (!string.IsNullOrEmpty(inspected) && !string.IsNullOrWhiteSpace(inspected))
                    {
                        pathes.AddIfNotExists(inspected);
                    }
                }
                foreach (var path in pathes)
                {
                    tw.WriteLine(path);
                }

            }
        }