Elmah.SccStamp.FindAll C# (CSharp) Méthode

FindAll() public static méthode

Finds and builds an array of SccStamp instances from all the SccAttribute attributes applied to the given assembly.
public static FindAll ( Assembly assembly ) : Elmah.SccStamp[]
assembly System.Reflection.Assembly
Résultat Elmah.SccStamp[]
        public static SccStamp[] FindAll(Assembly assembly)
        {
            if (assembly == null)
                throw new ArgumentNullException("assembly");

            var attributes = (SccAttribute[]) Attribute.GetCustomAttributes(assembly, typeof(SccAttribute), false);
            
            if (attributes.Length == 0)
                return new SccStamp[0];
            
            var list = new List<SccStamp>(attributes.Length);

            foreach (var attribute in attributes)
            {
                var id = attribute.Id.Trim();

                if (id.Length > 0 && string.Compare("$Id" + /* IMPORTANT! */ "$", id, true, CultureInfo.InvariantCulture) != 0)
                    list.Add(new SccStamp(id));
            }

            return list.ToArray();
        }

Usage Example

Exemple #1
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            //
            // Emit a script that emit version info and checks for updates.
            //

            writer.WriteLine(@"
                <script type='text/javascript' language='JavaScript'>
                    function onCheckForUpdate(sender) {
                        var script = document.createElement('script');
                        script.type = 'text/javascript';
                        script.language = 'JavaScript';
                        script.src = 'http://elmah.googlecode.com/svn/www/update.js?__=' + (new Date()).getTime();
                        document.getElementsByTagName('head')[0].appendChild(script);
                        return false;
                    }
                    var ELMAH = {
                        info : {
                            version     : '" + GetVersion() + @"',
                            fileVersion : '" + GetFileVersion() + @"',
                            type        : '" + Build.TypeLowercase + @"',
                            status      : '" + Build.Status + @"',
                            framework   : '" + Build.Framework + @"',
                            imageRuntime: '" + Build.ImageRuntimeVersion + @"'
                        }
                    };
                </script>");

            //
            // Title
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "PageTitle");
            writer.RenderBeginTag(HtmlTextWriterTag.H1);
            writer.Write(PageTitle);
            writer.RenderEndTag(); // </h1>
            writer.WriteLine();

            //
            // Speed Bar
            //

            SpeedBar.Render(writer,
                            SpeedBar.Home.Format(BasePageName),
                            SpeedBar.Help,
                            SpeedBar.About.Format(BasePageName));

            //
            // Content...
            //

            writer.RenderBeginTag(HtmlTextWriterTag.P);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "return onCheckForUpdate(this)");
            writer.AddAttribute(HtmlTextWriterAttribute.Title, "Checks if your ELMAH version is up to date (requires Internet connection)");
            writer.RenderBeginTag(HtmlTextWriterTag.Button);
            writer.Write("Check for Update");
            writer.RenderEndTag(); // </button>
            writer.RenderEndTag(); // </p>

            SccStamp[] stamps = SccStamp.FindAll(typeof(ErrorLog).Assembly);
            SccStamp.SortByRevision(stamps, /* descending */ true);

            writer.RenderBeginTag(HtmlTextWriterTag.P);
            writer.Write("This <strong>{0}</strong> ", Build.TypeLowercase);

            if (stamps.Length > 0)
            {
                writer.Write("(SCC #{0}) ", stamps[0].Revision.ToString("N0"));
            }

            writer.Write("build was compiled from the following sources for CLR {0}:", Build.ImageRuntimeVersion);

            writer.RenderEndTag(); // </p>

            //
            // Stamps...
            //

            writer.RenderBeginTag(HtmlTextWriterTag.Ul);

            foreach (SccStamp stamp in stamps)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.RenderBeginTag(HtmlTextWriterTag.Code);
                Server.HtmlEncode(stamp.Id, writer);
                writer.RenderEndTag(); // </code>
                writer.RenderEndTag(); // </li>
            }

            writer.RenderEndTag(); // </ul>
        }
All Usage Examples Of Elmah.SccStamp::FindAll