This commit is contained in:
John Jenko 2010-08-12 16:01:34 +00:00
parent f689cc42c5
commit 0a6f171f83
5 changed files with 364 additions and 0 deletions

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Volian.Base.Library")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Volian.Base.Library")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6de1141c-643a-40dd-b296-06eeff462603")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Volian.Base.Library
{
public static class VlnSettings
{
// This is used to toggle the colored text during the Data Conversion
// and will set the font and background in PROMS 2010 for Demo/Release mode (white background black text)
// or for Debug mode (shaded background, and color text on PDF output
// For PROMS 2010, this is set via the App.config setting:
// <appSettings>
// <add key ="Debug" value ="false"/>
// For DataLoader, this is set via the Debug checkbox on the form.
private static bool _DebugMode = true;
public static bool DebugMode
{
get { return _DebugMode; }
set { _DebugMode = value; }
}
private static string _TemporaryFolder = null;
public static string TemporaryFolder
{
get
{
if (_TemporaryFolder == null)
{
// This will create a Temp\VE-PROMS folder in the LocalSettings Folder.
//XP - C:\Documents and Settings\{user}\Local Settings\Application Data\Temp\VE-PROMS
//Vista - C:\Users\{user}\AppData\Local\Temp\VE-PROMS
_TemporaryFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Temp";
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
_TemporaryFolder += @"\VE-PROMS";
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
}
return _TemporaryFolder;
}
}
// used for Debug mode (at least for now)
// this is where the PDF 16-bit VE-PROMS output is placed and merge (via layers) into the PROMS 2010 PDF Output
private static string _OldPDFFolder = @"C:\Temp\16bit";
public static string OldPDFFolder
{
get { return VlnSettings._OldPDFFolder; }
set { VlnSettings._OldPDFFolder = value; }
}
}
}

View File

@ -0,0 +1,70 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AEEE9FD1-6892-45E2-A67E-418C06D46FF9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Volian.Base.Library</RootNamespace>
<AssemblyName>Volian.Base.Library</AssemblyName>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VlnSettings.cs" />
<Compile Include="vlnStackTrace.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,195 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace Volian.Base.Library
{
// This provides a more robust stack trace than what visual studio offers
public static class vlnStackTrace
{
public static string GetStack(string str, params object[] objects)
{
return string.Format(str, objects) + StackToString();
}
public static void ShowStack(string str, params object[] objects)
{
Console.WriteLine(string.Format(str, objects) + StackToString());
}
public static string GetStack()
{
return StackToString();
}
public static void ShowStack()
{
Console.WriteLine(StackToString());
}
private static string StackToString()
{
StringBuilder sb = new StringBuilder();
StackTrace st = new StackTrace(true);
StackFrame[] sfs = st.GetFrames();
int ii = 0;
string sLast = "";
string sThis = "";
int imax = MatchingStackFrame(sfs);
foreach (StackFrame sf in sfs)
{
if (imax == 0)
sb.Append(string.Format("\r\n{0}---------", "".PadLeft(ii++ * 2)));
imax--;
if (ii < 2) ii++;
else
{
string sMethod = sf.GetMethod().Name;
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
string sType = sf.GetMethod().ReflectedType.Name;
if (sf.GetFileLineNumber() != 0)
{
sMethod += string.Format(" {0}[{1}]", sf.GetFileName(), sf.GetFileLineNumber());
sThis = "";
}
else
{
sThis = sNamespace;
}
if (sLast == sThis && sThis != "")
sb.Append(string.Format("\t*.{0}.{1}", sType, sMethod));
else
sb.Append(string.Format("\r\n{0}{1}.{2}.{3}", "".PadLeft(ii++ * 2), sNamespace, sType, sMethod));
}
sLast = sThis;
}
return sb.ToString();
}
public static void ShowStackFirstLocal(string str)
{
Console.WriteLine(str + " " + StackToStringLocal(3,0));
}
public static void ShowStackLocal(string str,int start)
{
Console.WriteLine(str + " " + StackToStringLocal(start,1));
}
public static void ShowStackLocal(string str,int start, int limit)
{
Console.WriteLine(str + " " + StackToStringLocal(start, limit));
}
private static string StackToStringLocal(int start, int limit)
{
StringBuilder sb = new StringBuilder();
string sep = "Local Method - ";
StackTrace st = new StackTrace(true);
StackFrame[] sfs = st.GetFrames();
int count = 0;
int localCount = 0;
foreach (StackFrame sf in sfs)
{
count++;
if (count > start)
{
if (sf.GetFileLineNumber() != 0)
{
string sMethod = sf.GetMethod().Name;
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
string sType = sf.GetMethod().ReflectedType.Name;
sMethod += string.Format(" {0}[{1}]", sf.GetFileName(), sf.GetFileLineNumber());
sb.Append(sep + string.Format("{0}.{1}.{2}", sNamespace, sType, sMethod));
localCount ++;
if (localCount >= limit)
return sb.ToString();
sep = "\r\n" + "".PadRight(localCount *2);
}
}
}
if (localCount > 0)
return sb.ToString();
return "No Local Method";
}
public static string CalledFrom
{
get
{
StackTrace st = new StackTrace(true);
StackFrame[] sfs = st.GetFrames();
int count = 0;
foreach (StackFrame sf in sfs)
{
if (sf.GetFileLineNumber() != 0)
{
count++;
{
string sMethod = sf.GetMethod().Name;
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
string sType = sf.GetMethod().ReflectedType.Name;
sMethod += string.Format(" {0}[{1}]", sf.GetFileName(), sf.GetFileLineNumber());
if (count > 3)
return string.Format("{0}.{1}.{2}", sNamespace, sType, sMethod);
}
}
}
return "No Local Method";
}
}
private static StackFrame[] _LastSFS;
private static int MatchingStackFrame(StackFrame[] sfs)
{
int iFound = -1;
if (_LastSFS != null)
{
// start at the far end and work backward
for (int i = 1; iFound < 0 && i <= sfs.Length && i <= _LastSFS.Length; i++)
{
if (!Match(sfs[sfs.Length - i],_LastSFS[_LastSFS.Length - i]))
iFound = 1+ sfs.Length - i;
}
}
if (iFound < 0) iFound = sfs.Length;
_LastSFS = (StackFrame[])sfs.Clone();
return iFound;
}
private static bool Match(StackFrame stackFrame1, StackFrame stackFrame2)
{
if (stackFrame1.GetMethod().Name != stackFrame2.GetMethod().Name) return false;
if (stackFrame1.GetMethod().DeclaringType.FullName != stackFrame2.GetMethod().DeclaringType.FullName) return false;
if (stackFrame1.GetILOffset() != stackFrame2.GetILOffset()) return false;
return true;
}
public static bool ScrollInStack()
{
StackTrace st = new StackTrace(true);
StackFrame[] sfs = st.GetFrames();
bool retval = false;
foreach (StackFrame sf in sfs)
{
string sMethod = sf.GetMethod().Name;
string sNamespace = sf.GetMethod().ReflectedType.Namespace;
string sType = sf.GetMethod().ReflectedType.Name;
if (sMethod.ToUpper().Contains("SCROLL") || sType.ToUpper().Contains("SCROLL"))
{
retval = true;
Console.WriteLine("{0}.{1}.{2}", sNamespace, sType, sMethod);
}
}
return retval;
}
/// <summary>
/// This will clear the Output window when run in the Development Environment
/// Add EnvDTE and EnvDTE80 to references from .NET
/// </summary>
public static void ClearOutputWindow()
{
#if (DEBUG)
try
{
EnvDTE80.DTE2 dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");
dte2.ToolWindows.OutputWindow.ActivePane.Clear();
}
catch (Exception ex)
{
Console.WriteLine("ClearOutputWindow {0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
}
#endif
}
}
}