<HTML>
<HEAD>
<!-- Copyright 2001, 2002, 2003, 2004 Macromedia, Inc. All rights reserved. -->
<SCRIPT LANGUAGE="javascript">

//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelDisplayName
//
// DESCRIPTION:
//   Returns the name that should be displayed in the UI for
//   this Server Model
//
//   This value can be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getDisplayName()
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   string
//--------------------------------------------------------------------

function getServerModelDisplayName()
{
  return "ASP.NET C#"
}

//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelFolderName
//
// DESCRIPTION:
//   Returns the folder name that will be used for this Server Model
//   within the Configuration folder
//
//   This value can be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getFolderName()
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   string
//--------------------------------------------------------------------

function getServerModelFolderName()
{
  return "ASP.NET_Csharp";
}

//--------------------------------------------------------------------
// FUNCTION:
//   getServerInfo
//
// DESCRIPTION:
//   Returns a JavaScript Object, which can be accessed from within
//   the JavaScript code.
//
//   The entire object can be accessed through the JavaScript function:
//     dom.serverModel.getServerInfo();
//
//   The properties: serverName, serverLanguage, and serverVersion
//   are special properties, which can also be accessed with the
//   JavaScript functions:
//     dom.serverModel.getServerName()
//     dom.serverModel.getServerLanguage()
//     dom.serverModel.getServerVersion();
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Object
//--------------------------------------------------------------------

function getServerInfo()
{
  var obj = new Object();

  obj.serverName = "ASP.NET";
  obj.serverLanguage = "C#";
  obj.serverVersion = "1.0";
  obj.recordsetDisplayName = MM.LABEL_TitleDataSet;
  obj.recordsetBaseName = MM.LABEL_DataSetBaseName;
 
  return obj;
}


//--------------------------------------------------------------------
// FUNCTION:
//   getFileExtensions
//
// DESCRIPTION:
//   Returns a JavaScript Array of the file extensions which will
//   be listed as potential default file extensions on the Application
//   Server configuration page within the Site definition dialog.
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getFileExtensions()
{
  FileExtensionArray = new Array();

  FileExtensionArray[0] = ".aspx";
  FileExtensionArray[1] = ".ascx";
  FileExtensionArray[2] = ".asmx";
  FileExtensionArray[3] = ".cs";
  FileExtensionArray[4] = ".htm";
  FileExtensionArray[5] = ".html";
  FileExtensionArray[6] = ".inc";
  FileExtensionArray[7] = ".js";
  FileExtensionArray[8] = ".config";

  return FileExtensionArray;
}


//--------------------------------------------------------------------
// FUNCTION:
//   getServerSupportsCharset
//
// DESCRIPTION:
//   Returns true if the current server supports the given charset
//
//   The CharSet support be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getServerSupportsCharset(metaCharSetString)
//
// ARGUMENTS:
//   metaCharSetString - string - the value of the documents "charset="
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getServerSupportsCharSet( metaCharSetString )
{
  //Dot net running on a 2000 or greater server should support all characters
  return true;
}


//--------------------------------------------------------------------
// FUNCTION:
//   updatePageDirective
//
// DESCRIPTION:
//   This function is called when a user changes their document encoding
//   or the document type of their document.
//
// ARGUMENTS:
//   dom - The Document DOM of the document to be opened.
//
// RETURNS:
//   none
//--------------------------------------------------------------------

function updatePageDirective(dom)
{
  if (dom)
  {
    encoding = dom.getCharSet();
    if (encoding)
    {
      var docStr = dom.documentElement.outerHTML;
      var pageDirectiveStart = docStr.search( /<%@\s*Page/i );

      if( pageDirectiveStart > -1 )
      {
        var pageDirectiveEnd = 0;
        pageDirectiveEnd = docStr.indexOf("%>", pageDirectiveStart) + 2;

        if(pageDirectiveEnd > 1 && pageDirectiveEnd > pageDirectiveStart)
        {
          var oldLangStr = docStr.substring(pageDirectiveStart, pageDirectiveEnd);
          var newLangStr = oldLangStr;
          newLangStr = newLangStr.replace(/(ResponseEncoding=)"[\w-]*"/i, "$1\"" + encoding + "\""); // double quotes
          newLangStr = newLangStr.replace(/(ResponseEncoding=)'[\w-]*'/i, "$1'" + encoding + "'");   // single quotes
          if (newLangStr != oldLangStr)
          {
            var newDocStr = docStr.substring(0, pageDirectiveStart) +
                            newLangStr +
                            docStr.substring(pageDirectiveEnd);
            dom.documentElement.outerHTML = newDocStr;
          }
        }
      }
    }
  }
}



//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelDelimiters
//
// DESCRIPTION:
//   Returns the script delimiters which are used by the application
//   server, and states whether each can or cannot participate in
//   merging of code blocks.
//
//   This value can be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getDelimiters()
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getServerModelDelimiters()
{
	DelimArray = new Array();

	DelimObject = new Object();
	DelimObject["startPattern"]="<%";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=true;
	DelimArray[0]=DelimObject;

	DelimObject = new Object();
	DelimObject["startPattern"]="<%\\s*=";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=false;
	DelimArray[1]=DelimObject;

	DelimObject = new Object();
  // Note the extra (?!@) in pattern below. This means do not match <%@ if it is
  //   followed by another @. Also, the character matched by (?!@) is not extracted
  //   in the regexp. This case is needed in case we see a participant like:
  //   "<% @@param1@@ ...". We still want to strip the <% in this case.
	DelimObject["startPattern"]="<%\\s*@(?!@)";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=false;
	DelimArray[2]=DelimObject;

	DelimObject = new Object();
	DelimObject["startPattern"]="<%\\s*#";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=false;
	DelimArray[3]=DelimObject;

	return DelimArray;
}


//--------------------------------------------------------------------
// FUNCTION:
//   getLanguageSignatures
//
// DESCRIPTION:
//   Returns the method and array signatures used by the scripting
//   language.
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getLanguageSignatures()
{
	Signatures = new Object();

	// method signature
	Signatures["Method"] = "$$RETURNTYPE $$METHODNAME($$ARGUMENT, $$ARGUMENT) $$THROWS $$EXCEPTION, $$EXCEPTION";
//	Signatures["Method"] = "$$METHODNAME($$ARGUMENT, $$ARGUMENT) $$THROWS $$EXCEPTION, $$EXCEPTION, $$RETURNTYPE";

	// constructor signature
	Signatures["Constructor"] = "$$METHODNAME($$ARGUMENT, $$ARGUMENT)";

	// dropcode signatures
	Signatures["Dropcode"] = "$$RETURNTYPE a$$RETURNVALUE = $$OBJECTNAME.$$METHODNAME($$ARGUMENT, $$ARGUMENT);"
	Signatures["ConstructorDropcode"] = "$$METHODNAME a$$RETURNVALUE = new $$METHODNAME($$ARGUMENT, $$ARGUMENT);"
	Signatures["VoidDropcode"] = "$$OBJECTNAME.$$METHODNAME($$ARGUMENT, $$ARGUMENT);"

	// array signature
	Signatures["Array"] = "$$ARRAYNAME[]";
	Signatures["ArrayBracket"] = "[]";

	// reference signature
	Signatures["Reference"] = "";

	// pointer signature
	Signatures["Pointer"] = "";

	//throws signature
	Signatures["Throws"] = "throws";

	// try signature
	Signatures["Try"] = "try{";
	Signatures["EndTry"] = "}";

	// catch signature
	Signatures["Catch"] = "catch($$EXCEPTION e){";
	Signatures["EndCatch"] = "}";

	Signatures["BeginBlockComment"] = "/*";
	Signatures["EndBlockComment"] = "*/";

	// data type mappings
	PrimitiveTypes = new Object();
	Signatures["PrimitiveTypes"] = PrimitiveTypes;
	PrimitiveTypes["VOID"] = "void";
	PrimitiveTypes["BOOLEAN"] = "bool";
	PrimitiveTypes["I1"] = "sbyte";	// 8-bit signed integer
	PrimitiveTypes["U1"] = "byte";	// 8-bit unsigned integer
	PrimitiveTypes["I2"] = "short";	// 16-bit signed integer
	PrimitiveTypes["U2"] = "ushort";	// 16-bit unsigned integer
	PrimitiveTypes["CHAR"] = "char";	// character
	PrimitiveTypes["I4"] = "int";	// 32-bit signed integer
	PrimitiveTypes["U4"] = "uint";	// 32-bit unsigned integer
	PrimitiveTypes["I8"] = "long";	// 64-bit signed integer
	PrimitiveTypes["U8"] = "ulong";	// 64-bit unsigned integer
	PrimitiveTypes["R4"] = "float";	// 32-bit floating point
	PrimitiveTypes["R8"] = "double";	// 64-bit floating point

	return Signatures;
}


//--------------------------------------------------------------------
// FUNCTION:
//   canRecognizeDocument
//
// DESCRIPTION:
//   This function is called when a user attempts to open a document
//   whose file extension matches two or more Document Types.
//
// ARGUMENTS:
//   dom - The Document DOM of the document to be opened.
//
// RETURNS:
//   integer +ve integer if document is identified.
//           -ve integer if not.
//--------------------------------------------------------------------

function canRecognizeDocument(dom)
{
  var retVal = (-1);
  var langRE = /<%\s*@\s*page(\s*.*\s*)language\s*=\s*(\"|\')?c#(\"|\')?/i;
  var wslangRE = /<%\s*@\s*webservice(\s*.*\s*)language\s*=\s*(\"|\')?c#(\"|\')?/i;
  var uclangRE = /<%\s*@\s*control(\s*.*\s*)language\s*=\s*(\"|\')?c#(\"|\')?/i;

  var oHTML = dom.documentElement.outerHTML;

  if ((oHTML.search(langRE) > (-1)) || (oHTML.search(wslangRE) > (-1)) || (oHTML.search(uclangRE) > (-1)))
  {
    retVal = 1;
  }
  if(retVal == (-1))
  {
	// There isn't an @ page language directive on the page.
	// Look for a server-side script language tag.
	var scriptTags = dom.getElementsByTagName("script")

	for(var i=0; i < scriptTags.length; i++)
	{
	  // Check if it's a server side script tag.
	  if(scriptTags[i].getAttribute("runat") && scriptTags[i].getAttribute('language')){

	    // Check if it's VB.
	    if(scriptTags[i].getAttribute('language').toLowerCase() == "c#")
		{
		  retVal = 1;
		  // We only care about the first one. Exit the loop.
		  break;
		}
	  }
	}
  }
  if((retVal == (-1)) && (dom != null) && (dom.URL != null))
  {
    //  As is pointed out in http://bugapp/bugapp/detail.asp?ID=159326
    //  ASP.NET allows a page, user control, web service, etc., to omit
    //  the keyword immediately after the @.  So, for example, it is perfectly
    //  OK to have the following in an aspx page:
    //
    //  <%@ language="c#" %>
    //
    //  This is completely equivalent to:
    //
    //  <%@page language="c#" %>
    //
    //  In an ascx file, the keyword "control" after the @ is implied if
    //  missing and so on.  This is spelled out here:
    //
    //  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconpagedirectives.asp
    //
    //  In the code below we try to detect that situation.  Note that we
    //  are a little careful to only do this special processing if we know
    //  that we have a file with the right kind of extension.  Otherwise,
    //  we might pick up a false positive if the content of another file
    //  (like an inc file) happens to have the "magic" string that we are
    //  looking for.  By only searching in cases where we know that the
    //  file extension is right we limit the cases where we might screw up.

    var lastDot = dom.URL.lastIndexOf(".");
    if (lastDot > -1)
    {
      var fileExt = dom.URL.substring(lastDot).toLowerCase();
      if ((fileExt == ".aspx") || (fileExt == ".ascx") || (fileExt == ".asmx"))
      {
        var genericLangRE = /<%\s*@(\s*.*\s*)language\s*=\s*(\"|\')?c#(\"|\')?/i;
        if (oHTML.search(genericLangRE) > (-1))
        {
          retVal = 1;
        }
      }
    }
  }

  return retVal;
}
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
