コード例 #1
0
ファイル: BundleManagerBase.cs プロジェクト: retahc/old-code
        // Don't just retrieve the template instance; also Apply() it to our project,
        // instantiating whatever providers or whatever the template defines.

        public StructureTemplate UseNamespaceTemplate(string ns, string declloc,
                                                      IWarningLogger log)
        {
            if (proj == null)
            {
                throw new InvalidOperationException("Must call SetProject before UseNamespaceMaster!");
            }

            StructureTemplate tmpl = GetNamespaceTemplate(ns, log);

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

            if (sused[ns])
            {
                return(tmpl);
            }

            if (tmpl.Apply(proj, declloc, log))
            {
                return(null);
            }

            sused[ns] = true;
            return(tmpl);
        }
コード例 #2
0
ファイル: BundleManagerBase.cs プロジェクト: retahc/old-code
        public StructureTemplate GetNamespaceTemplate(string ns, IWarningLogger log)
        {
            if (sinfo.ContainsKey(ns))
            {
                return(sinfo[ns]);
            }

            string cfg = MBuildPrefix + ns + "." + DefaultStructureClass;
            Type   t   = null;

            if (LookupType(cfg, out t, log))
            {
                log.Error(9999, "Error looking up namespacep parameter class " + cfg,
                          null);
                return(null);
            }

            if (t == null)
            {
                log.Error(9999, "No bundle defines the namespace parameter class" +
                          cfg, null);
                return(null);
            }

            StructureTemplate stmpl = (StructureTemplate)Activator.CreateInstance(t);

            MethodInfo mi  = t.GetMethod("ApplyDefaults");
            object     ret = mi.Invoke(stmpl, new object[] { this, log });

            if ((bool)ret)
            {
                return(null);
            }

            sinfo[ns] = stmpl;
            sused[ns] = false;

            return(stmpl);
        }
コード例 #3
0
        // Context -- used for the lookup of names of this provider's
        // targets. This needs to be here for providers created by
        // structure templates, which need context to instantiate any
        // structure-bound items they may reference

        public abstract void AddContextStructure(StructureTemplate st);
コード例 #4
0
ファイル: ProviderBuilder.cs プロジェクト: emtees/old-code
	// Context -- used for the lookup of names of this provider's
	// targets. This needs to be here for providers created by 
	// structure templates, which need context to instantiate any
	// structure-bound items they may reference

	public abstract void AddContextStructure (StructureTemplate st);
コード例 #5
0
ファイル: NameLookupContext.cs プロジェクト: emtees/old-code
	public void UseStructure (StructureTemplate st)
	{
	    Type stype = st.GetType ();

	    known_structs[stype] = st;

	    UseRawNamespace (stype.Namespace);
	}
コード例 #6
0
ファイル: RegexMatcher.cs プロジェクト: emtees/old-code
	public RegexMatcher (StructureTemplate stmpl)
	{
	    this.stmpl = stmpl;
	}
コード例 #7
0
ファイル: RegexMatcher.cs プロジェクト: emtees/old-code
	public RegexMatcher ()
	{
	    stmpl = null;
	}
コード例 #8
0
ファイル: WrenchProvider.cs プロジェクト: emtees/old-code
	public override void AddContextStructure (StructureTemplate st)
	{
	    namecontext.UseStructure (st);
	}
コード例 #9
0
ファイル: BundleManagerBase.cs プロジェクト: retahc/old-code
        // Rule template helpers

        public bool GetTemplateForRule(string ns, Type rtype, out TargetTemplate ttmpl, IWarningLogger log)
        {
            ttmpl = null;

            StructureTemplate stmpl = GetNamespaceTemplate(ns, log);

            if (stmpl == null || !sused[ns])
            {
                log.Error(9999, "Trying to use structure template of namespace " +
                          ns + ", but either it wasn't defined or it hasn't been " +
                          "initialized yet.", null);
                return(true);
            }

            // See if we can find a type that has a StructureBinding to tmpl
            // and a RuleBinding to rtype.

            string pns = MBuildPrefix + ns;
            Type   ttype = null, stype = stmpl.GetType();

            foreach (Assembly assy in BundleAssemblies)
            {
                foreach (Type t in assy.GetExportedTypes())
                {
                    if (t.Namespace != pns)
                    {
                        continue;
                    }

                    if (!t.IsSubclassOf(typeof(TargetTemplate)))
                    {
                        continue;
                    }

                    object[] attrs = t.GetCustomAttributes(typeof(StructureBindingAttribute), false);

                    if (attrs.Length == 0)
                    {
                        continue;
                    }

                    StructureBindingAttribute sba = (StructureBindingAttribute)attrs[0];

                    if (sba.StructureType == null)
                    {
                        continue;
                    }

                    if (!sba.StructureType.Equals(stype))
                    {
                        continue;
                    }

                    attrs = t.GetCustomAttributes(typeof(RuleBindingAttribute), false);

                    if (attrs.Length == 0)
                    {
                        continue;
                    }

                    if (!((RuleBindingAttribute)attrs[0]).RuleType.Equals(rtype))
                    {
                        continue;
                    }

                    if (ttype != null)
                    {
                        log.Warning(9999, "Two hits for rule template: " + ttype.ToString() +
                                    " and " + t.ToString(), rtype.ToString());
                    }

                    ttype = t;
                }
            }

            if (ttype != null)
            {
                ttmpl = (TargetTemplate)Activator.CreateInstance(ttype, stmpl);
            }

            return(false);
        }