Skip to content

Commit

Permalink
Fixed some null-reference problems.
Browse files Browse the repository at this point in the history
Added interop sample to manufacturing. Used XsdGenerator to generate XSD from OrderService.Messages. Used Xsd.exe to generate classes from generated schema.
  • Loading branch information
Dahan, Udi committed Dec 6, 2008
1 parent 5e9835c commit 5dd7344
Show file tree
Hide file tree
Showing 11 changed files with 496 additions and 7 deletions.
65 changes: 65 additions & 0 deletions Samples/Manufacturing/InteropPartner/InteropPartner.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AF9929C8-85B8-4A36-9EC8-E46C17FE3B65}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>InteropPartner</RootNamespace>
<AssemblyName>InteropPartner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Messaging" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="schema1_schema0.cs" />
</ItemGroup>
<ItemGroup>
<None Include="schema0.xsd" />
<None Include="schema1.xsd" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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>
41 changes: 41 additions & 0 deletions Samples/Manufacturing/InteropPartner/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Messaging;
using System.Xml.Serialization;

namespace InteropPartner
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Using straight xml serialization and msmq to test interop.");
Console.WriteLine("To exit, enter 'q'. Press 'Enter' to send a message.");

string queueName = string.Format("FormatName:DIRECT=OS:{0}\\private$\\messagebus", Environment.MachineName);

MessageQueue q = new MessageQueue(queueName);

XmlSerializer serializer = new XmlSerializer(typeof(OrderMessage), new Type[] { typeof(OrderLine) });

string line = null;
while ((line = Console.ReadLine().ToLower()) != "q")
{
OrderMessage m1 = new OrderMessage();
m1.PurchaseOrderNumber = Guid.NewGuid().ToString();
m1.ProvideBy = DateTime.Now;
m1.PartnerId = Guid.NewGuid();
m1.OrderLines = new OrderLine[] { new OrderLine { ProductId = Guid.NewGuid(), Quantity = 10F } };
m1.Done = true;

Message toSend = new Message();
serializer.Serialize(toSend.BodyStream, m1);

q.Send(toSend, MessageQueueTransactionType.Single);
Console.WriteLine("Sent order {0}", m1.PurchaseOrderNumber);
}
}
}
}
36 changes: 36 additions & 0 deletions Samples/Manufacturing/InteropPartner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("InteropPartner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InteropPartner")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[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("6e1c25c9-5c7e-4f9c-beee-576f1558a5f8")]

// 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 Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
53 changes: 53 additions & 0 deletions Samples/Manufacturing/InteropPartner/schema0.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://tempuri.net/OrderService.Messages" xmlns="http://tempuri.net/OrderService.Messages" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://microsoft.com/wsdl/types/" />
<xs:element name="OrderStatusChangedMessage" nillable="true" type="OrderStatusChangedMessage" />
<xs:complexType name="OrderStatusChangedMessage">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="PurchaseOrderNumber" type="xs:string" />
<xs:element minOccurs="1" maxOccurs="1" name="PartnerId" xmlns:q1="http://microsoft.com/wsdl/types/" type="q1:guid" />
<xs:element minOccurs="1" maxOccurs="1" name="Status" type="OrderStatusEnum" />
<xs:element minOccurs="0" maxOccurs="1" name="OrderLines" type="ArrayOfOrderLine" />
</xs:sequence>
</xs:complexType>
<xs:element name="OrderMessage" nillable="true" type="OrderMessage" />
<xs:complexType name="OrderMessage">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Done" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="ProvideBy" type="xs:dateTime" />
<xs:element minOccurs="0" maxOccurs="1" name="OrderLines" type="ArrayOfOrderLine" />
<xs:element minOccurs="0" maxOccurs="1" name="PurchaseOrderNumber" type="xs:string" />
<xs:element minOccurs="1" maxOccurs="1" name="PartnerId" xmlns:q1="http://microsoft.com/wsdl/types/" type="q1:guid" />
</xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfOrderLine" nillable="true" type="ArrayOfOrderLine" />
<xs:complexType name="ArrayOfOrderLine">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="OrderLine" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:element name="OrderLine" nillable="true" type="OrderLine" />
<xs:complexType name="OrderLine">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="ProductId" xmlns:q1="http://microsoft.com/wsdl/types/" type="q1:guid" />
<xs:element minOccurs="1" maxOccurs="1" name="Quantity" type="xs:float" />
</xs:sequence>
</xs:complexType>
<xs:element name="CancelOrderMessage" nillable="true" type="CancelOrderMessage" />
<xs:complexType name="CancelOrderMessage">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="PurchaseOrderNumber" type="xs:string" />
<xs:element minOccurs="1" maxOccurs="1" name="PartnerId" xmlns:q1="http://microsoft.com/wsdl/types/" type="q1:guid" />
</xs:sequence>
</xs:complexType>
<xs:element name="OrderStatusEnum" type="OrderStatusEnum" />
<xs:simpleType name="OrderStatusEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="Tentative" />
<xs:enumeration value="Recieved" />
<xs:enumeration value="Authorized" />
<xs:enumeration value="Rejected" />
<xs:enumeration value="Accepted" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
8 changes: 8 additions & 0 deletions Samples/Manufacturing/InteropPartner/schema1.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://microsoft.com/wsdl/types/" elementFormDefault="qualified" targetNamespace="http://microsoft.com/wsdl/types/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
Loading

0 comments on commit 5dd7344

Please sign in to comment.