# 19 Ağustos 2006 Cumartesi

ActiveWriter is a DLinq designer like addin for Visual Studio 2005 to design a domain model and to generate code decorated with ActiveRecord attributes.

 

 

It supports / will support:

  • Modeling
    Classes (Almost done)
    Class properties (Almost done)
    Setting a property as primary keys (Done)
    Setting more than one property as composite key (TBI)
    Many to One (Done), One to One, Many to Many relations (TBI)
    Nested classes (TBI)
    ... and more (I'm targeting to support the whole ActiveRecord model)
  • Model validation
    Current build validates most common things like classes without names, spaces in class names etc.
  • Drag and drop of table(s) from Server Explorer
    Can place tables, populate properties. I'm working on relations right now.
  • Automatic generation of source code of the model on save.
    Not implemented yet, but I know how to do it. Right now, it goes through .tt file.
  • Multiple database types as drag/drop source.
    Working on SQL Server right now. Oracle and others will follow.

I use the current CTP of DSL Tools to build the base. There are no downloadable bits right now, since I have to get a VSIP licence to make it run without the SDK.

I don't know to what extent I can open the source. I'll sure make the source downloadable but since part of the code is generated by DSL Tools and there's this VSIP licence, I may not be able to licence it under BSD or something. I'll look for it.

Anyway, I believe it will be a nice addin to have for people working with ActiveRecord/NHibernate. I'm doing my best to release a preview in one or two months.

Comments and suggestions are welcome.


posted on 19 Ağustos 2006 Cumartesi 11:02:33 UTC  #   

It's a black hole since its so massive that even a tiny piece of information on it's usage cannot escape out. Start writing an addin for Visual Studio and you'll find lots of information on the net. Enter into realms of Server Explorer, and you'll feel the massive darkness.

I'm coding and addin for Visual Studio 2005 using DSL Tools. Apart from the relatively steep learning curve of DSL Tools, it was going fine. By the very nature of the project, I started thinking on adding drag and drop of tables from Server Explorer. There are some DSRef and UIHierarchy usage examples on the net, so I thought it will be a piece of cake, until I find out there's no simple way of getting the underlying object model for data connections in Server Explorer, thanks to Microsoft's ability to mark everything Server Explorer as Private or Internal.

Long story short, after long nights and hours of Reflector and thousands of evasive maneuvers against the missile fired by my wife, here's how you get the DbConnection instance of Server Explorer holding the tables dropped on your design surface:

        private static DataConnection GetDataConnection(DTE dte, string itemName)

        {

            IntPtr ptr = IntPtr.Zero;

            try

            {

                if (((IServiceProvider)dte).QueryService(ref ServerExplorer, ref IUnknown, out ptr) >= 0)

                {

                    object o = Marshal.GetObjectForIUnknown(ptr);

                    if (o != null)

                    {

                        object dataConnectionsNode = GetField(o, "lastBrowseObjectNodeSite");

                        if (dataConnectionsNode != null)

                        {

                            INodeSite nodeSite =

                                (INodeSite)dataConnectionsNode;

 

                            INodeSite[] nodes = nodeSite.FindChildrenByLabel(itemName);

                            if (nodes != null && nodes.Length > 0)

                            {

                                object expNode = GetField(nodes[0], "expNode");

                                if (expNode != null)

                                {

                                    object nestedHierarchy = GetField(expNode, "nestedHierarchy");

                                    if (nestedHierarchy != null)

                                    {

                                        DataConnection connection =

                                            GetProperty(nestedHierarchy, "DataConnection") as DataConnection;

                                        if (connection != null)

                                        {

                                            return connection;

                                        }

                                    }

                                }

                            }

                        }

                    }

                }

            }

            finally

            {

                Marshal.Release(ptr);

            }

 

            return null;

        }

        private static object GetField(object o, string fieldName)

        {

            if (o != null && !String.IsNullOrEmpty(fieldName))

                return o.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(o);

 

            return null;

        }

 

        private static object GetProperty(object o, string fieldName)

        {

            if (o != null && !String.IsNullOrEmpty(fieldName))

                return o.GetType().GetProperty(fieldName).GetValue(o, null);

 

            return null;

        }

Once you get DataConnection, try ConnectionSupport.ProviderObject property to get the actual DbConnection. Happily, VS loaded addins cannot load new assemblies into AppDomain but at least allowed reflection.

posted on 19 Ağustos 2006 Cumartesi 09:49:55 UTC  #   

...but Foreign Key support is just useless, especially for SqlConnection. Just look at the table signature:

ColumnName DataType Description

constraint_catalog

String

Catalog the constraint belongs to.

constraint_schema

String

Schema that contains the constraint.

constraint_name

String

Name.

table_catalog

String

Table Name constraint is part of.

table_schema

String

Schema that that contains the table.

table_name

String

Table Name

constraint_type

String

Type of constraint. Only "FOREIGN KEY" is allowed.

is_deferrable

String

Specifies whether the constraint is deferrable. Returns NO.

initially_deferred

String

Specifies whether the constraint is initially deferrable. Returns NO.

Quite disappointing, since there's no sign of columns involved. And there's no other GetSchema() way to get them. OracleConnection, on the other hand has a collection called ForeignKeyColumns, which returns columns included for a given FK relationship in a given table. Once you have the FK relation, you should query both sides to get the full column list, though, but better than nothing.

So, with SqlConnection, I use sp_fkeys in ActiveWriter. I wish I could just use GetSchema(), to keep things simple. Sad.

posted on 19 Ağustos 2006 Cumartesi 08:59:42 UTC  #   
# 18 Ağustos 2006 Cuma

My previous blogging attempt was a failure marely because of lack of time and attention. This time, I'm heading the opposite.

Anyway. I'm a consultant living in Istanbul, I code in c# and tell people how to code.

Just a reminder: I restarted blogging today but I posted older projects with historically correct dates. Written in the past, posted today! Don't be confused.

posted on 18 Ağustos 2006 Cuma 22:07:45 UTC  #   
# 09 Şubat 2006 Perşembe

Please Note: If you're using VS 2008, you don't need this tool anymore. 2008 has this functionality built-in, look for the dropdown on top of the resource editor.

Introduction

In Visual Studio 2005, strongly-typed code for resource files (.resx files) are automatically generated when you save them. The generated class, however, cannot be accessed externally since the class is marked as internal.

This little add-in just instructs the generation process to build a Public class. To use it, just change the Custom Tool property of any resource file from ResXFileCodeGenerator to ResXFilePublicCodeGenerator.

After you make any changes and save the file, IDE will auto-generate a Public strongly-typed class for your resource.

Licence

The component and source is provided "as is" and there are neither warranties to the quality of the work nor any expressed or implied agreements that the programmer will release any updates. The programmer will release updates and provide any support at his own discretion.

External code mentioned in credits may subject to their own licence terms.

1.0.0.1 Update:
Fixed the issue with VB.Net root namespaces. This is, in fact, reported months ago but I totally forgot to fix it. I apoligize from all VB.Net users for the trouble.

Download

v1.0.0.1

Credits

Includes some code from Daniel Cazzulino’s XSD -> Classes Generator Custom Tool article.

VS Integration classes from http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=4AA14341-24D5-45AB-AB18-B72351D0371C

posted on 09 Şubat 2006 Perşembe 00:10:42 UTC  #   
# 07 Ağustos 2003 Perşembe

Note: This is a very old piece of work and I'm not maintaining it anymore.

Introduction

Three custom controls, a button, an image button and a hyperlink which opens a new window with given attributes when clicked.

Supported properties:

  • Left: Gets or sets the left position of the new window.
  • Location: Specifies whether to display the input field for entering URLs directly into the new browser.
  • MenuBar: Specifies whether to display the menu bar.
  • Resizable: Specifies whether to display resize handles at the corners of the new window.
  • ScrollBars: Specifies whether to display horizontal and vertical scroll bars.
  • Status: Specifies whether to add a status bar at the bottom of the window.
  • ToolBar: Specifies whether to display the browser toolbar, making buttons such as Back, Forward, and Stop available.
  • Top: Gets or sets the top position of the new window.
  • WindowHeight: Specifies the height of the new window.
  • WindowName: Specifies the window name to refer to the new window programmatically.
  • WindowWidth: Specifies the width of the new window.
  • Plus the properties derived from the respective parent control.

 Controls supports design-time use. You may want to add them to your toolbox:

  1. On the Tools menu, click Customize Toolbox.
  2. On the .NET Framework Components tab of the Customize ToolBox dialog box, click the Browse button. Find Altinoren.HTMLControls.BrowserWindow.dll, select it, and click Open to add BWButton, BWHyperLink and BWImageButton  to the list of components in the Customize Toolbox dialog box.
  3. Select BrowserWindowBWButton, BWHyperLink and BWImageButton in the list of .NET Framework components and click OK. Three new controls are added to the Toolbox.

You may also use the controls directly from your "\Bin" folder, without adding them to your toolbox. See the demo page.

Licence

The component and source is provided "as is" and there are neither warranties to the quality of the work nor any expressed or implied agreements that the programmer will release any updates. The programmer will release updates and provide any support at his own discretion.

Download

v2.0

  • New: BrowserWindow now includes a Button, an ImageButton and a HyperLink control.

Credits

Original idea: RemoteWindow from MetaBuilders. I modified Andy's code but the original idea worth 99% of the control. While there, be sure to check his other controls.

posted on 07 Ağustos 2003 Perşembe 22:27:25 UTC  #   
# 08 Aralık 2002 Pazar

Introduction

This is a button control that hides or shows other controls on the page when clicked. An alternative text for the button is shown when it hides another control, allowing to toggle between two states.

All the action is handled on the client, there's no need to do a roundtrip to the server. This is useful when you want show a selectably advanced interface to the user, like showing advanced search features with a button click (web 2.0 nowadays? :)

Supported properties:

  • AlternativeText: Alternative text to be displayed on the button when in Hidden state.
  • ControlToShowHide: The name of the control to show or hide.
  • InitialState: Starting state of the control that the button handles. Visible or Hidden.
  • PersistState: Whether the last state at the client will be persisted after a postback.
  • Plus properties derived from the Button control.

The control supports design-time use. You may want to add it to your toolbox:

  1. On the Tools menu, click Customize Toolbox.
  2. On the .NET Framework Components tab of the Customize ToolBox dialog box, click the Browse button. Find Altinoren.HTMLControls.ShowHideButton.dll, select it, and click Open to add ShowHideButton to the list of components in the Customize Toolbox dialog box.
  3. Select ShowHideButton in the list of .NET Framework components and click OK. ShowHideButton is added to the Toolbox.

You may use the control directly from your "\Bin" folder. See ShowHideButton.aspx included in the .zip file.

Works on IE5+ and NS7. Ignores click on Opera 6.05.

Note: Since the control prevents postback, setting CommandName and CommandArgument does nothing.

To Do:

  • Include a LinkButton and an ImageButton with the same capability.

Licence

The component and source is provided "as is" and there are neither warranties to the quality of the work nor any expressed or implied agreements that the programmer will release any updates. The programmer will release updates and provide any support at his own discretion.

Download

v1.0

  • Feature: The control can persist the latest state at the client after a postback. Check PersistState property.

v0.9.1

  • BugFix: Solved a minor issue on toolbox icon.

v0.9

  • Feature: Now supports NS7.

v0.8.5

  • BugFix: The dropdown to select ControlToShowHide in Properties window works properly when used in a user control.
  • BugFix: Does not show self among the available choices in ControlToShowHide dropdown.
  • Temporary Hack: Does not do a postback on NS and Opera browsers.
  • Temporary Hack: Works when there's a validator control on the page.
posted on 08 Aralık 2002 Pazar 00:04:32 UTC  #   
# 09 Temmuz 2002 Salı

Introduction

Notification is a class you can use to access notification related methods (SHNotificationAdd, SHNotificationRemove, etc.) of Pocket PC 2002 devices on .NET Compact Framework.

The code is briefly tested on .NET Compact Framework Beta 1 and Pocket PC 2002 Emulator. There may be some bugs to handle.

To Do:

  • Icon support.
  • Add Update methods.
  • Test it on Windows CE .NET with a relevant Platform Builder image.

License

The soure is provided "AS IS" with no warranties. Since the original code is sent to Usenet does not comes with specific restrictions, I believe you may freely use the whole code for commercial and personal use. I don't impose restrictions on my part.

Download

v0.1

Credits

Original code sent to Usenet by:

Seth Demsey
Program Manager
Net Compact Framework
in message <NGe9hNxECHA.1560@cpmsftngxa07>
posted on 09 Temmuz 2002 Salı 22:57:31 UTC  #   
# 15 Mayıs 2002 Çarşamba

INFO: Not supported anymore. This is here for archiving purposes only.

Introduction

DocListX is a free ActiveX control with source code, to be used (mainly) in Embedded Visual Basic 3.0 to create directory lists as in Pocket Word or Pocket Excel. It gives EVB access to the CCeDocList class, part of the MFC library.

Warning: The control is currently in alpha stage, with some features are still unimplemented (menu support, etc.). It is developed using Embedded Visual C++ on the Pocket PC Emulator and didn't tested neither on a real device nor on PocketPC 2002 environment.

Since the control is not tested properly, there should be many bugs to be handled. I currently does not plan to work on this control anymore.

To Do:

  • Should be alignable to the full client area
  • May have it's own menu
  • Should implement events
  • SetBorderStyle
  • Many More...

Licence

DocListX is distributed under the GNU Lesser General Public License (LGPL). For some background information about this license, you may wish to visit the GNU web site.

The LGPL license allows you to link DocListX into your software, with no real obligation other than that any modifications you make to DocListX itself are contributed back. Linking your application with an LGPL'd library does not require you to make the source of your application available - that requirement is a characteristic of the stronger GPL license.

Download

v0.7.0 Alpha

Requires MFC.

Credits

Original idea from Devbuzz column of Carl Devis.

posted on 15 Mayıs 2002 Çarşamba 22:50:29 UTC  #