Esempio n. 1
0
        /// <summary>
        /// Performs the basic check for the value in the existing hash tables, so we don't do it for every single type of element
        /// </summary>
        /// <param name="relObj">Existing relation object</param>
        /// <param name="a">Name of the resource</param>
        /// <returns>Returns whether the item was created or successfully added.</returns>
        private bool BasicResolve(ElementRelationship relObj, string a)
        {
            bool retval = false;

            if (this.Elements.ContainsKey(a))
            {
                relObj.Supporter = this.Elements[a];
            }
            else if (tmpElements.ContainsKey(a))
            {
                relObj.Supporter = tmpElements[a];
            }
            else
            {
                System.Console.Out.WriteLine("Unknown supporter: " + a);
                ProgramElement R = new RumpElement(a);
                tmpElements.Add(a, R);
                relObj.Supporter = R;
                retval           = true;
            }
            return(retval);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs the relationobject and guarantees that the component objects exist in the hash table.
        /// </summary>
        /// <param name="CompleteFileName">Name of the Dependent Element (calling or including or Linking out to... )</param>
        /// <param name="ReferenceFileName">Name of the Required Element (called, created, loaded, or instantiated)</param>
        /// <param name="Type">The type of reference</param>
        /// <returns>Elementrelationship with object pointers to elements</returns>
        /// Note : Elements can include Absolute filenames (which must be unique) or ClassIDs (similarly unique) or URLS (similarly unique)
        /// While building the list of elements, Put new Elements into tmpElements to avoid issues with Iterator Disruption
        ElementRelationship IResolver.ResolveReference(string CompleteFileName, string ReferenceFileName, RelationShipType Type)
        {
            CompleteFileName  = CompleteFileName.ToLower();
            ReferenceFileName = ReferenceFileName.ToLower();
            ElementRelationship retval = new ElementRelationship();

            retval.Dependent = this.Elements[CompleteFileName];
            retval.Relation  = Type;

            if (Type == RelationShipType.RelationCOM)
            {
                if (BasicResolve(retval, ReferenceFileName))
                {
                    System.Console.Out.WriteLine("Unknown COM supporter: " + ReferenceFileName);
                }
                retval.Supporter.ElementType = ElementType.COMobject;

                return(retval);
            } // End COM relation

            if (Type == RelationShipType.RelationLink)
            { // Must handle Http:// , or relative files (my.css, my.html, /subdir/subsubdir/my.html, ~/Food/my.aspx.
                if (ReferenceFileName.IndexOf("://") >= 0)
                {
                    // it's an HTTP tag.
                    if (this.Elements.ContainsKey(ReferenceFileName))
                    {
                        retval.Supporter = Elements[ReferenceFileName];
                        return(retval);
                    }
                    else if (this.tmpElements.ContainsKey(ReferenceFileName))
                    {
                        retval.Supporter = tmpElements[ReferenceFileName];
                        return(retval);
                    }
                    else
                    {
                    }
                }
            }
            if (Type == RelationShipType.RelationInclude)
            {
                // have to make sure that paths are appropriately combined.
                // Given c:\p1\p2\p3\p4\source.txt and ..\..\inc\foo\myfile.txt give :

                if (ReferenceFileName.Contains("/"))
                {
                    ReferenceFileName = ReferenceFileName.Replace("/", "\\");
                }
                string b = CompleteFileName.Remove(CompleteFileName.Length - Path.GetFileName(CompleteFileName).Length);
                string c = Path.GetFullPath(RootFolderName + ReferenceFileName).ToLower();
                string a = Path.GetFullPath(b + ReferenceFileName).ToLower();

                if (this.Elements.ContainsKey(a))
                {
                    retval.Supporter = this.Elements[a];
                    return(retval);
                }
                else if (this.Elements.ContainsKey(c))
                {
                    retval.Supporter = this.Elements[c];
                    return(retval);
                }
                else if (this.tmpElements.ContainsKey(a))
                {
                    retval.Supporter = this.tmpElements[a];
                    return(retval);
                }
                System.Console.Out.WriteLine("Unknown File supporter: " + a);
                ProgramElement R = new RumpElement(a);
                R.ElementType = ElementType.BinaryFile;
                tmpElements.Add(a, R);
                retval.Supporter = R;
                return(retval);
            }

            return(retval);
        }