Skip to content

Commit

Permalink
Lots and lots of refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
soshimozi committed Sep 26, 2011
1 parent 0b03069 commit 27e6442
Show file tree
Hide file tree
Showing 34 changed files with 354 additions and 350 deletions.
2 changes: 1 addition & 1 deletion SocketService.Framework.Client/Event/JoinRoomEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public string EventName
get { return "JoinRoomEvent"; }
}

public RoomVariable [] RoomVariables { get; set; }
public SharedObject [] RoomVariables { get; set; }

public UserListEntry [] Users { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions SocketService.Framework.Client/Event/PublicMessageEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public string EventName
get { return "PublicMessageEvent"; }
}

public string Zone
public int ZoneId
{
get;
set;
}

public string Room
public int RoomId
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public string EventName

public int RoomId { get; set; }
public string Name { get; set; }
public RoomVariable Variable { get; set; }
public SharedObject Value { get; set; }
public RoomVariableUpdateAction Action { get; set; }

public int ZoneId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ namespace SocketService.Framework.Client.Response
[Serializable]
public class GetRoomVariableResponse : IResponse
{
public string Room
public int ZoneId
{
get;
set;
}

public int RoomId
{
get;
set;
Expand All @@ -21,7 +27,7 @@ public string Name
set;
}

public RoomVariable Variable
public SharedObject Value
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public string Name
/// <value>
/// The value.
/// </value>
public RoomVariable Variable
public SharedObject Value
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public string Name
/// <value>
/// The value.
/// </value>
public RoomVariable Variable
public SharedObject Value
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
namespace SocketService.Framework.SharedObjects
{
[Serializable]
public class ServerObject
public class SharedObject
{
private Hashtable data = new Hashtable();

/// <summary>
/// Gets the read only copy.
/// </summary>
/// <returns></returns>
public ServerObjectRO GetReadOnlyCopy()
public SharedObjectRO GetReadOnlyCopy()
{
return new ServerObjectRO(data);
return new SharedObjectRO(data);
}

/// <summary>
Expand All @@ -26,16 +26,16 @@ public ServerObjectRO GetReadOnlyCopy()
/// <param name="elementName">Name of the element.</param>
/// <param name="value">The value.</param>
/// <param name="dataType">Type of the data.</param>
public void SetElementValue(string elementName, object value, ServerObjectDataType dataType)
public void SetElementValue(string elementName, object value, SharedObjectDataType dataType)
{
if (!data.ContainsKey(elementName))
{
data.Add(elementName, new ServerObjectDataHolder());
data.Add(elementName, new SharedObjectDataHolder());
}

(data[elementName] as ServerObjectDataHolder).Value = value;
(data[elementName] as SharedObjectDataHolder).Value = value;

(data[elementName] as ServerObjectDataHolder).DataType = dataType;
(data[elementName] as SharedObjectDataHolder).DataType = dataType;

}

Expand All @@ -50,7 +50,7 @@ public object GetValueForElement(string elementName)
object value = null;
if (data.ContainsKey(elementName))
{
value = (data[elementName] as ServerObjectDataHolder).Value;
value = (data[elementName] as SharedObjectDataHolder).Value;
}

return value;
Expand All @@ -61,14 +61,14 @@ public object GetValueForElement(string elementName)
/// </summary>
/// <param name="elementName">Name of the element.</param>
/// <returns></returns>
public ServerObjectDataType GetDataTypeForElement(string elementName)
public SharedObjectDataType GetDataTypeForElement(string elementName)
{
if( !data.ContainsKey(elementName) )
{
throw new ArgumentException();
}

return (data[elementName] as ServerObjectDataHolder).DataType;
return (data[elementName] as SharedObjectDataHolder).DataType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace SocketService.Framework.SharedObjects
{
[Serializable]
public class ServerObjectDataHolder
public class SharedObjectDataHolder
{
private int dataType;
private object value;
Expand All @@ -29,9 +29,9 @@ public object Value
/// <value>
/// The type of the data.
/// </value>
public ServerObjectDataType DataType
public SharedObjectDataType DataType
{
get { return (ServerObjectDataType)dataType; }
get { return (SharedObjectDataType)dataType; }
set { dataType = (int)value; }
}

Expand All @@ -40,77 +40,77 @@ private void SetValue(object value)
this.value = value;

// default to an object
int dataType = (int)ServerObjectDataType.BzObject;
int dataType = (int)SharedObjectDataType.BzObject;

if (value != null)
{
if (value is Int32)
{
dataType = (int)ServerObjectDataType.Integer;
dataType = (int)SharedObjectDataType.Integer;
}
else if (value is Int16)
{
dataType = (int)ServerObjectDataType.Short;
dataType = (int)SharedObjectDataType.Short;
}
else if (value is Int64)
{
dataType = (int)ServerObjectDataType.Long;
dataType = (int)SharedObjectDataType.Long;
}
else if (value is String)
{
dataType = (int)ServerObjectDataType.String;
dataType = (int)SharedObjectDataType.String;
}
else if (value is float)
{
dataType = (int)ServerObjectDataType.Float;
dataType = (int)SharedObjectDataType.Float;
}
else if (value is Double)
{
dataType = (int)ServerObjectDataType.Double;
dataType = (int)SharedObjectDataType.Double;
}
else if (value is Char)
{
dataType = (int)ServerObjectDataType.Character;
dataType = (int)SharedObjectDataType.Character;
}
else if (value is Byte)
{
dataType = (int)ServerObjectDataType.Byte;
dataType = (int)SharedObjectDataType.Byte;
}
else if (value is Array)
{
Type valueType = value.GetType();

if (valueType.GetElementType() == typeof(int))
{
dataType = (int)ServerObjectDataType.IntegerArray;
dataType = (int)SharedObjectDataType.IntegerArray;
}
else if (value is Int16)
{
dataType = (int)ServerObjectDataType.ShortArray;
dataType = (int)SharedObjectDataType.ShortArray;
}
else if (value is Int64)
{
dataType = (int)ServerObjectDataType.LongArray;
dataType = (int)SharedObjectDataType.LongArray;
}
else if (value is String)
{
dataType = (int)ServerObjectDataType.StringArray;
dataType = (int)SharedObjectDataType.StringArray;
}
else if (value is float)
{
dataType = (int)ServerObjectDataType.FloatArray;
dataType = (int)SharedObjectDataType.FloatArray;
}
else if (value is Double)
{
dataType = (int)ServerObjectDataType.DoubleArray;
dataType = (int)SharedObjectDataType.DoubleArray;
}
else if (value is Char)
{
dataType = (int)ServerObjectDataType.CharacterArray;
dataType = (int)SharedObjectDataType.CharacterArray;
}
else if (value is Byte)
{
dataType = (int)ServerObjectDataType.ByteArray;
dataType = (int)SharedObjectDataType.ByteArray;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SocketService.Framework.SharedObjects
{
public enum ServerObjectDataType : int
public enum SharedObjectDataType : int
{
Integer,
Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ namespace SocketService.Framework.SharedObjects
{

[Serializable]
public class ServerObjectRO
public class SharedObjectRO
{
ServerObject innerObject;
SharedObject innerObject;
private Hashtable data;

/// <summary>
/// Initializes a new instance of the <see cref="ServerObjectRO"/> class.
/// Initializes a new instance of the <see cref="SharedObjectRO"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
/// <param name="dataType">Type of the data.</param>
public ServerObjectRO(string name, object value, ServerObjectDataType dataType)
public SharedObjectRO(string name, object value, SharedObjectDataType dataType)
{
innerObject = new ServerObject();
innerObject = new SharedObject();
innerObject.SetElementValue(name, value, dataType);
}

/// <summary>
/// Initializes a new instance of the <see cref="ServerObjectRO"/> class.
/// Initializes a new instance of the <see cref="SharedObjectRO"/> class.
/// </summary>
/// <param name="data">The data.</param>
public ServerObjectRO(Hashtable data)
public SharedObjectRO(Hashtable data)
{
this.data = data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RoomVariable.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ServerObject.cs" />
<Compile Include="ServerObjectDataHolder.cs" />
<Compile Include="ServerObjectDataType.cs" />
<Compile Include="ServerObjectRO.cs" />
<Compile Include="SharedObject.cs" />
<Compile Include="SharedObjectDataHolder.cs" />
<Compile Include="SharedObjectDataType.cs" />
<Compile Include="SharedObjectRO.cs" />
<Compile Include="UserListEntry.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 1 addition & 1 deletion SocketService.Framework/App.Config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="ServerDataEntities" connectionString="metadata=res://*/ServerDataModel.csdl|res://*/ServerDataModel.ssdl|res://*/ServerDataModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\ServerData.sdf;Password=p*vU^dJ1!EW&quot;" providerName="System.Data.EntityClient" />
<add name="ServerDataEntities" connectionString="metadata=res://*/Data.ServerDataModel.csdl|res://*/Data.ServerDataModel.ssdl|res://*/Data.ServerDataModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\ServerData.sdf;Password=p*vU^dJ1!EW&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions SocketService.Framework/SocketService.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@
<Compile Include="Configuration\SocketServiceConfiguration.cs" />
<Compile Include="Configuration\PluginInfoInstanceCollection.cs" />
<Compile Include="Configuration\PluginInfoInstanceElement.cs" />
<Compile Include="Data\Room.cs" />
<Compile Include="Data\User.cs" />
<Compile Include="Data\Zone.cs" />
<Compile Include="Messaging\BaseMessageHandler.cs" />
<Compile Include="Messaging\ICommand.cs" />
<Compile Include="Messaging\MessageServer.cs" />
<Compile Include="Messaging\MSMQQueueWatcher.cs" />
<Compile Include="Messaging\MSMQQueueWrapper.cs" />
<Compile Include="ServerDataModel.Designer.cs">
<Compile Include="Data\ServerDataModel.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>ServerDataModel.edmx</DependentUpon>
Expand Down Expand Up @@ -130,7 +127,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EntityDeploy Include="ServerDataModel.edmx">
<EntityDeploy Include="Data\ServerDataModel.edmx">
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>ServerDataModel.Designer.cs</LastGenOutput>
</EntityDeploy>
Expand Down
Loading

0 comments on commit 27e6442

Please sign in to comment.