Notes

General Notes

Overriding core.css in master page

Cascading Style Sheets

This is the capability provided by CSS to allow style information from several sources to be blended together. The cascade is an ordered sequence of style sheets where rules in later sheets have greater precedence than earlier ones.

The following is a sample head section from a SharePoint 2007 master page. Notice the location of the <SharePoint:CssLink runat=”server”/> and the <SharePoint:Theme runat=”server”/> tags. The CssLink tag references the /_layouts/1033/styles/core.css. The Theme tag references the currently loaded theme css file.


<HEAD runat="server">

    <META Name="GENERATOR" Content="Microsoft SharePoint">

    <META Name="progid" Content="SharePoint.WebPartPage.Document">

    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

    <META HTTP-EQUIV="Expires" content="0">

    <SharePoint:RobotsMetaTag runat="server"/>

    <Title ID=onetidTitle><asp:ContentPlaceHolder id=PlaceHolderPageTitle runat="server"/></Title>

    <SharePoint:CssLink runat="server"/>

    <link rel="stylesheet" type="text/css" href="<% $SPUrl:~SiteCollection/Style Library/~language/Custom Styles/pb_Core.css %>" />

    <SharePoint:Theme runat="server"/>

    <SharePoint:ScriptLink language="javascript" name="core.js" Defer="true" runat="server"/>

    <SharePoint:CustomJSUrl runat="server"/>

    <SharePoint:SoapDiscoveryLink runat="server"/>

    <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server"/>

    <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>

</HEAD>

namespace QSystem
{
    //
    // Copyright © Sidney Mark Croy 2008-2010 GNU Lesser General Public License
    //
    // This file is part of QSystem.
    //
    // QSystem is free software; you can redistribute it and/or modify
    // it under the terms of the GNU Lesser General Public License as published by
    // the Free Software Foundation; either version 3 of the License, or
    // (at your option) any later version.
    //
    // QSystem is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    // GNU Lesser General Public License for more details.
    //
    // You should have received a copy of the GNU Lesser General Public License
    // along with this program. If not, see <<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.
    //
    using System;
    using System.Threading;

    /// <summary>
    /// Executes a specified action asynchronously.
    /// Sample 1: AsyncAction.Execute( delegate
    /// {
    ///     Console.WriteLine( "executing" );
    /// } );
    /// Sample 2: AsyncAction.Execute( delegate
    /// {
    ///     Console.WriteLine( "executing" );
    /// }, returnCallback, "This is an identifier" );
    /// void returnCallback( object state )
    /// {
    ///     Console.WriteLine( state + " completed" );
    /// }
    /// Sample 3: AsyncAction.Execute( delegate
    /// {
    ///     Console.WriteLine( "executing" );
    /// }, errorCallback, "This is an identifier" );
    /// void errorCallback( Exception e, object state )
    /// {
    ///     Console.WriteLine( state + " " + e.Message );
    /// }
    /// Sample 4: AsyncAction.Execute( delegate
    /// {
    ///     Console.WriteLine( "executing" );
    /// }, returnCallback, errorCallback, "This is an identifier" );
    /// void returnCallback( object state )
    /// {
    ///     Console.WriteLine( state + " completed" );
    /// }
    /// void errorCallback( Exception e, object state )
    /// {
    ///     Console.WriteLine( state + " " + e.Message );
    /// }
    /// </summary>
    [Serializable]
    public class AsyncAction
    {
        #region Constructors

        AsyncAction( Action action, ReturnCallback returnCallback, object state, ErrorCallback errorCallback )
        {
            InternalParameter parm = new InternalParameter
            {
                action = action,
                errorCallback = errorCallback,
                returnCallback = returnCallback,
                state = state
            };
            AsyncCallback callback = new AsyncCallback( internalCallback );
            AsyncResult asyncResult = new AsyncResult( parm );
            callback.BeginInvoke( asyncResult, null, null );
        }

        #endregion Constructors

        #region Delegates

        public delegate void ErrorCallback( Exception exception, object state );

        /// <summary>
        /// Represents the method that is called upon completion of the specified action.
        /// </summary>
        /// <param name="state"></param>
        public delegate void ReturnCallback( object state );

        #endregion Delegates

        #region Properties

        /// <summary>
        /// Gets whether the associated action has completed.
        /// </summary>
        public bool IsCompleted
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets whether the action is in error.
        /// </summary>
        public bool IsInError
        {
            get;
            private set;
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// Execute the specified action asynchronously.
        /// </summary>
        /// <param name="action">Encapsulates a method that takes no parameters and does not return a value.</param>
        public static AsyncAction Execute( Action action )
        {
            AsyncAction a = new AsyncAction( action, null, null, null );
            return a;
        }

        /// <summary>
        /// Execute the specified action asynchronously.
        /// </summary>
        /// <param name="action">Encapsulates a method that takes no parameters and does not return a value.</param>
        /// <param name="errorCallback">A method to call if any exceptions are caught during the execution of the action. The method signature must conform to the ErrorCallback delegate signature.</param>
        /// <param name="state">An object that is passed to the errorCallback method.</param>
        public static AsyncAction Execute( Action action, ErrorCallback errorCallback, object state )
        {
            AsyncAction a = new AsyncAction( action, null, state, errorCallback );
            return a;
        }

        /// <summary>
        /// Execute the specified action asynchronously.
        /// </summary>
        /// <param name="action">Encapsulates a method that takes no parameters and does not return a value.</param>
        /// <param name="returnCallback">A method to call upon action completion. The method signature must conform to the ReturnCallback delegate signature.</param>
        /// <param name="state">An object that is passed to the returnCallback method.</param>
        public static AsyncAction Execute( Action action, ReturnCallback returnCallback, object state )
        {
            AsyncAction a = new AsyncAction( action, returnCallback, state, null );
            return a;
        }

        /// <summary>
        /// Execute the specified action asynchronously.
        /// </summary>
        /// <param name="action">Encapsulates a method that takes no parameters and does not return a value.</param>
        /// <param name="returnCallback">A method to call upon action completion. The method signature must conform to the ReturnCallback delegate signature.</param>
        /// <param name="errorCallback">A method to call if any exceptions are caught during the execution of the action. The method signature must conform to the ErrorCallback delegate signature.</param>
        /// <param name="state">An object that is passed to the returnCallback method. If any exceptions are caught during the execution of the action, it is also passed to the errorCallback method.</param>
        public static AsyncAction Execute( Action action, ReturnCallback returnCallback, ErrorCallback errorCallback, object state )
        {
            AsyncAction a = new AsyncAction( action, returnCallback, state, errorCallback );
            return a;
        }

        void internalCallback( object o )
        {
            InternalParameter parm = ( o as IAsyncResult ).AsyncState as InternalParameter;

            Action action = parm.action;
            try
            {
                action.Invoke( );
            }
            catch ( Exception e )
            {
                IsInError = true;
                if ( parm.errorCallback != null )
                    parm.errorCallback.DynamicInvoke( new object[ ] { new AsyncActionException( e ), parm.state } );
                else
                    throw new AsyncActionException( e );
            }

            if ( !IsInError &&
                parm.returnCallback != null )
                parm.returnCallback.DynamicInvoke( new object[ ] { parm.state } );

            IsCompleted = true;
        }

        #endregion Methods

        #region Nested Types

        internal class AsyncResult : IAsyncResult
        {
            #region Constructors

            public AsyncResult( object asyncState )
            {
                AsyncState = asyncState;
            }

            #endregion Constructors

            #region Properties

            public object AsyncState
            {
                get;
                private set;
            }

            public WaitHandle AsyncWaitHandle
            {
                get
                {
                    throw new NotImplementedException( );
                }
            }

            public bool CompletedSynchronously
            {
                get
                {
                    throw new NotImplementedException( );
                }
            }

            public bool IsCompleted
            {
                get
                {
                    throw new NotImplementedException( );
                }
            }

            #endregion Properties
        }

        internal class InternalParameter
        {
            #region Properties

            public Action action
            {
                get;
                set;
            }

            public ErrorCallback errorCallback
            {
                get;
                set;
            }

            public ReturnCallback returnCallback
            {
                get;
                set;
            }

            public object state
            {
                get;
                set;
            }

            #endregion Properties
        }

        #endregion Nested Types
    }
}

 

Note this is a test.

Leave a comment

About

Writing on the Wall is a newsletter for freelance writers seeking inspiration, advice, and support on their creative journey.