コード例 #1
0
        /// <summary>Static data initialization.</summary>
        static HeaderNameExtensions()
        {
            Type mpeg4HeaderNameStartCode = typeof(Mpeg4HeaderName);

            ICollection <Mpeg4HeaderName> allContainerHeaders = new HashSet <Mpeg4HeaderName>();

            _headerNameForHeaderStartCode = new Dictionary <uint, Mpeg4HeaderName>();
            _headerAttributes             = new Dictionary <Mpeg4HeaderName, HeaderAttributes>();
            _allowedNextHeaders           = new Dictionary <Mpeg4HeaderName, HashSet <uint> >();

            // Create the list to feed to the headers that can be in all container headers
            allContainerHeaders.Add(Mpeg4HeaderName.Root);

            // Use reflection to find the attributes describing the codec identifiers
            foreach (Mpeg4HeaderName headerName in Enum.GetValues(mpeg4HeaderNameStartCode))
            {
                if (headerName == Mpeg4HeaderName.Unknown)
                {
                    continue;
                }

                string name = Enum.GetName(mpeg4HeaderNameStartCode, headerName);

                FieldInfo        fieldInfo  = mpeg4HeaderNameStartCode.GetField(name);
                Mpeg4Attribute[] attributes = (Mpeg4Attribute[])fieldInfo.GetCustomAttributes(typeof(Mpeg4Attribute), false);

                if (headerName == Mpeg4HeaderName.Root)
                {
                    // The root container has no metadata and does not occur in any other header
                    _headerAttributes.Add(headerName, new HeaderAttributes(new uint[0], HeaderFlags.MasterHeader, new Mpeg4HeaderName[0]));
                }
                else if (attributes != null && attributes.Length == 1)
                {
                    HeaderAttributes headerAttributes = GetHeaderAttributes(headerName, attributes[0], allContainerHeaders);
                    _headerAttributes.Add(headerName, headerAttributes);

                    // Fill the _headerNameForHeaderStartCode collection
                    if (headerName != Mpeg4HeaderName.VopWithShortHeader)                       // Special handling for short video headers
                    {
                        foreach (uint headerStartCode in headerAttributes.HeaderStartCodes)
                        {
                            _headerNameForHeaderStartCode.Add(headerStartCode, headerName);
                        }
                    }
                }
                else
                {
                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "No attributes for {0}. Please add attributes to the HeaderName enumeration.", headerName));
                }
            }

            // Use reflection to fill the _allowedNextHeaders collection
            // This can not be done in the foreach loop above because the we need the start codes for all
            // Mpeg4HeaderNames. This list is complete when the foreach loop above is done.
            foreach (Mpeg4HeaderName headerName in Enum.GetValues(mpeg4HeaderNameStartCode))
            {
                string name = Enum.GetName(mpeg4HeaderNameStartCode, headerName);

                FieldInfo        fieldInfo  = mpeg4HeaderNameStartCode.GetField(name);
                Mpeg4Attribute[] attributes = (Mpeg4Attribute[])fieldInfo.GetCustomAttributes(typeof(Mpeg4Attribute), false);

                if (attributes == null || attributes.Length == 0 || attributes[0].AllowedNextHeaders == null)
                {
                    continue;
                }

                HashSet <uint> allowedHeaders = new HashSet <uint>();

                foreach (Mpeg4HeaderName allowedNextHeader in attributes[0].AllowedNextHeaders)
                {
                    ICollection <uint> allowedHeaderStartCodes = _headerAttributes[allowedNextHeader].HeaderStartCodes;

                    foreach (uint allowedHeaderStartCode in allowedHeaderStartCodes)
                    {
                        allowedHeaders.Add(allowedHeaderStartCode);
                    }
                }
                _allowedNextHeaders.Add(headerName, allowedHeaders);
            }

            CheckSuitableParents();
        }
コード例 #2
0
 IColumnConfiguration <TModel> IColumnConfiguration <TModel> .SetHeaderAttributes(
     IDictionary <string, object> attributes)
 {
     HeaderAttributes = HeaderAttributes.Merge(attributes);
     return(this);
 }
コード例 #3
0
 IColumnConfiguration <TModel> IColumnConfiguration <TModel> .SetHeaderCssClass(string @class)
 {
     HeaderAttributes = HeaderAttributes.Merge(new { @class });
     return(this);
 }
コード例 #4
0
 IColumnConfiguration <TModel> IColumnConfiguration <TModel> .SetHeaderAttributes(object attributes)
 {
     HeaderAttributes = HeaderAttributes.Merge(attributes);
     return(this);
 }