/// This is fake class for quick copy paste. Usage:
/// type HowTo. - the intellisense will display the names you have figured out for each fake method
/// select the name from the , click in it , right button , G , will get you there ,
/// copy paste the text , Alt + F, C to close and remember to delete the fake call.
///
public class HowTo
{
public static void UseRegexesWithWhiteSpace()
{
//how-to use regexes with white space
// Regex re = new Regex(
// @" # This pattern matches Foo
// (?i) # turn on insensitivity
// # The Foo bit
// \b(Foo)\b "
// , RegexOptions.IgnorePatternWhitespace ) ;
// for ( Match m = re.Match( "foo bar Foo" ) ; m.Success ; m = m.NextMatch() ;
} //eof method
public static void DisplayJavaScriptConfirmationDialog()
{
//Active_chkbox.Attributes.Add("OnClick" , "return (confirm('Do you want do disable this user'));");
} //eof method
public static void RegisterPageStartUpScript ( )
{
//how-to Page.RegisterStartupScript(@"startup",@"");
//string JaScript = " " ;
//Response.Write( JaScript );
} //eof method RegionsterPageStartUpScript
public static void AddCallingMethodNameToDebug()
{
string code = @"
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
string mName = st.GetFrame(1).GetMethod().Name;
" ;
} //eof method AddCallingMethodNameToDebug
public static void SettersAndGetters ()
{
//how-to generate those in textpad F8
// how-to Generate member accessors , properties for C# asp.net with textpad
// how-to setters and getters
// find:^(.*)$
// replace:private string s\1 ; \n public string \1 { \n \t\t get { return s\1 ; } \n \t\t set { s\1 = value ; } \n } //comm -- eof \1 property \n\n
//find:^(.*) (.*)$
//private string s\1 ; \n public string \1 { \n \t\t get { return s\1 ; } \n \t\t set { s\1 = value ; } \n } //comm -- eof \1 property \n\n
//
//private \1 _\2 ; \npublic \1 \2 { \n \t\t get { return _\2 ; } \n \t\t set { _\2 = value ; } \n } //eof property \2 \n\n\n
//
////for the constructor
//_\2= this.\2 ;
//
////for the passing to the constuctor
//\1 _\2 ,
} //eof method SettersAndGetters
public static void ListAllDbObjects()
{
/*
--HOW-TO LIST ALL PROCEDURE IN A DATABASE
select s.name from sys.objects s where type = 'P' or type='UP'
-- GET THE GENERATED ONES ONLY
select s.name from sysobjects s where type = 'P' and s.name like '%gsp%'
--HOW-TO LIST ALL TRIGGERS BY NAME IN A DATABASE
select s.name from sysobjects s where type = 'TR'
--HOW-TO LIST TABLES IN A DATABASE
select s.name from sysobjects s where type = 'U'
--how-to list all system tables in a database
select s.name from sysobjects s where type = 's'
--how-to list all the views in a database
select s.name from sysobjects s where type = 'v'
Similarly you can find out other objects created by user, simple change type =
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
IF = In-lined table-function
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table ( this is the one I discussed above in the example)
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure
*/
} //eof method
public static void GetProcedureMetaData()
{
string answer = @"
select PARAMETER_NAME as 'COLUMN_NAME', DATA_TYPE , CHARACTER_MAXIMUM_LENGTH AS 'MAX_LENGTH', IS_RESULT , PARAMETER_MODE from INFORMATION_SCHEMA.PARAMETERS where SPECIFIC_NAME='Login_Check'
Select * from INFORMATION_SCHEMA.Routines --returns stored procedures and functions
exec sp_HelpText 'Login_Check'
";
answer = string.Empty;
} //eof method
public static void GetRowColumnValuesFromDs()
{
//(ds.Tables["TableName"].Rows[0]["ColumnName"] == DBNull.Value) ? false : (bool)ds.Tables["TableName"].Rows[0]["ColumnName"];
} //eof method
public static void CopyMeAsTemplateMethod()
{ } //eof method
public static void ReflectionExample()
{
//Type objectType = testObject.GetType();
//ConstructorInfo[] info = objectType.GetConstructors();
//MethodInfo[] methods = objectType.GetMethods();
//// get all the constructors
//Console.WriteLine("Constructors:");
//foreach (ConstructorInfo cf in info)
//{
// Console.WriteLine(cf);
//}
//Console.WriteLine();
//// get all the methods
//Console.WriteLine("Methods:");
//foreach (MethodInfo mf in methods)
//{
// Console.WriteLine(mf);
//}
}
public static void shortcuts ()
{
string _shortcuts =
@"
//how-to shortcuts
Ctrl + Shift + F -- recursive find
F3 -- find next occurence
Ctrl + H -- find and replace
Ctrl + M + M -- collapse method
Ctrl + B --- set a break point
CTRL + “-” and CTRL + SHIFT + “-” -- web browser like backward and forward in code
Ctrl + Tab --- shift tabs
Shift + F5 --- stop debugging
Ctrl + I --- fast search
F5 -- start debugging
Tryf = try and finally block
Prop = property with get and set accessor
Switch = switch statement with default
Alt + W , L -- close all windows
Alt + W , 1 -- open the first window
Alt + F , F , 1 -- open the latest file I closed
Ctrl + F2 , Tab -- go to the methods dropdown , type a letter to get to the name of the method
Alt + L --- select the Solution Explorer
Ctrl + Shift + Z -- press 2 (needs arsclip (google download arsclip)) -- get the second latest entry from my clipboard
";
} //eof shortcuts
public static void redirectToCurrentUrl ()
{
string _redirectToCurrentUrl =
@"
Response.Redirect ( System.IO.Path.GetFileName ( System.Web.HttpContext.Current.Request.Url.AbsolutePath ) , false );
";
} //eof method
public static void formTypes ()
{
string _formTypes =
@"
//how-to forms 1 - Empty Search Form , 2 - Filled Form , 3 - Empty New form ( new Margin Data , new Project )
//how-to formTypes
//, 4 - filled search form from get by id procedure
// 5 - FilledSearchForm (coming from params)
";
} //eof formTypes
public static void GetTheFileNameWithoutTheExtension ()
{
string s =
@"how-to get the file name requested without the extension in asp.net";
/*debugStart Utils.Debugger.WriteIf ( "My page name without extension is " +
System.IO.Path.GetFileNameWithoutExtension (
System.Web.HttpContext.Current.Request.Url.AbsolutePath ) );
/*debugEnd*/
} //eof methoed
public static void GetThePhysicalRootPathNoExtension ()
{
//how-to get the physical root path on the file system of the application
//string rootPath = Server.MapPath("~"); Utils.Debugger.WriteIf ( "My rootPath is " + rootPath );
} //eof method
public static void AccessConfVariables ()
{
//how-to access conf variables BL.Conf.Instance.Vars [ "varName" ] would give you "theVarName ;
} //eof method
public static void GetRowColumnValue ()
{
//how-to get row column value
//(ds.Tables["TableName"].Rows[0]["ColumnName"] == DBNull.Value ) ? false : (bool)ds.Tables["TableName"].Rows[0]["ColumnName"] ;
} //eof method
public static void GenerateExtendedPropertiesForATable ()
{
//table column
//find:^(.*) (.*)$
//Replace:
//EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'title="\2",visible="1",fs="Basic Details",readonly="1"' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'\1', @level2type=N'COLUMN',@level2name=N'\2'
} //eof method
public static void RedirectToTheCurrentURL ()
{
//how-to redirect to current url = users.aspx or projects.aspx
//Response.Redirect( System.IO.Path.GetFileName ( System.Web.HttpContext.Current.Request.Url.AbsolutePath ) , false );
} //eof method
public static void THEORY ()
{
//EVENTS AND DELEGATES IN ASP.NET -- http://msdn.microsoft.com/en-us/library/17sde2xt.aspx
} //eof method
} //eof class
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!