This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Xml; | |
| public class GenerateXml { | |
| private static void Main() { | |
| XmlDocument doc = new XmlDocument(); | |
| XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null); | |
| doc.AppendChild(docNode); | |
| XmlNode productsNode = doc.CreateElement("products"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static byte GetPositionHigherBit(int value) | |
| { | |
| for (byte kk = 31; kk > 0; kk--) | |
| if ((value & (int)(Math.Pow(2, kk))) == (int)(Math.Pow(2, kk))) return kk; | |
| return 0; | |
| } | |
| private static int InvertBits(int value) | |
| { | |
| var posbit = GetPositionHigherBit(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.Win32; | |
| ... | |
| RegistryKey masterKey = Registry.LocalMachine.CreateSubKey | |
| ("SOFTWARE\\Test\\Preferences"); | |
| if (masterKey == null) | |
| { | |
| Console.WriteLine ("Null Masterkey!"); | |
| } | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void ClearFolder(string FolderName) | |
| { | |
| DirectoryInfo dir = new DirectoryInfo(FolderName); | |
| foreach (FileInfo fi in dir.GetFiles()) | |
| { | |
| fi.IsReadOnly = false; | |
| fi.Delete(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Returns the path (with ending backslash) of current executing assembly | |
| /// </summary> | |
| /// <returns>Path of executing assembly</returns> | |
| public static string AssemblyPath () { | |
| return Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location) + | |
| Path.DirectorySeparatorChar; | |
| } | |
| /// <summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Shows how to return a deep copy clone of an object. | |
| class CloneTest : ICloneable | |
| { | |
| public int SomeProperty { get; set; } | |
| public object Clone() | |
| { | |
| CloneTest clone = new CloneTest(); | |
| clone.SomeProperty = this.SomeProperty; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var metadata = sf.GetAllClassMetadata().ToList(); | |
| IDictionary<string,IClassMetadata> data = sf.GetAllClassMetadata(); | |
| //Dictionary<string, SingleTableEntityPersister> lstTable = sf.GetAllClassMetadata().ToDictionary(x => x.Key, x=> x.Value); | |
| foreach (var table in metadata) | |
| { | |
| Console.WriteLine("List {0}", table.ToString()); | |
| } | |
| foreach(KeyValuePair<string,IClassMetadata> entry in data) | |
| { | |
| Console.WriteLine("Value {0} {1}",entry.Key,entry.Value.EntityName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const string Connstring = "server=SWIGVA01-SRV341;database=LeafPoint_Global;" + | |
| "User Id=user;Password=pwd;"; | |
| configuration= Fluently.Configure() | |
| .Database(MsSqlConfiguration | |
| .MsSql2008 | |
| .ConnectionString(Connstring).ShowSql()) | |
| .Mappings(m => m.FluentMappings | |
| .AddFromAssemblyOf<FunctionMap>() | |
| //.Conventions.Add(new PrimaryKeyNameConvention()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static ISessionFactory CreateSessionFactory() | |
| { | |
| //const string Connstring = "server=SWIGVA01-SRV341;database=LeafPoint_Global;" + | |
| // "User Id=lp_global;Password=lp_gl0b4l;"; | |
| const string Connstring = @"server=.\SQLEXPRESS;database=SimpleDB;" + | |
| "Integrated Security=SSPI;"; | |
| return Fluently.Configure() | |
| .Database(MsSqlConfiguration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| shut down SQL Server from services | |
| open cmd window (as admin) and run single-user mode as local admin with this command | |
| c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -m -s SQLEXPRESS | |
| open another cmd window (as admin) | |
| open sqlcmd |