{"action":"created","issue":{"url":"https://api.github.com/repos/MarimerLLC/csla/issues/442","labels_url":"https://api.github.com/repos/MarimerLLC/csla/issues/442/labels{/name}","comments_url":"https://api.github.com/repos/MarimerLLC/csla/issues/442/comments","events_url":"https://api.github.com/repos/MarimerLLC/csla/issues/442/events","html_url":"https://github.com/MarimerLLC/csla/issues/442","id":107606804,"number":442,"title":"Translate name of business assemblies to short codes","user":{"login":"rockfordlhotka","id":2333134,"avatar_url":"https://avatars.githubusercontent.com/u/2333134?v=3","gravatar_id":"","url":"https://api.github.com/users/rockfordlhotka","html_url":"https://github.com/rockfordlhotka","followers_url":"https://api.github.com/users/rockfordlhotka/followers","following_url":"https://api.github.com/users/rockfordlhotka/following{/other_user}","gists_url":"https://api.github.com/users/rockfordlhotka/gists{/gist_id}","starred_url":"https://api.github.com/users/rockfordlhotka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rockfordlhotka/subscriptions","organizations_url":"https://api.github.com/users/rockfordlhotka/orgs","repos_url":"https://api.github.com/users/rockfordlhotka/repos","events_url":"https://api.github.com/users/rockfordlhotka/events{/privacy}","received_events_url":"https://api.github.com/users/rockfordlhotka/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MarimerLLC/csla/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/MarimerLLC/csla/milestones/16","html_url":"https://github.com/MarimerLLC/csla/milestones/4.6.300","labels_url":"https://api.github.com/repos/MarimerLLC/csla/milestones/16/labels","id":1339544,"number":16,"title":"4.6.300","description":"","creator":{"login":"rockfordlhotka","id":2333134,"avatar_url":"https://avatars.githubusercontent.com/u/2333134?v=3","gravatar_id":"","url":"https://api.github.com/users/rockfordlhotka","html_url":"https://github.com/rockfordlhotka","followers_url":"https://api.github.com/users/rockfordlhotka/followers","following_url":"https://api.github.com/users/rockfordlhotka/following{/other_user}","gists_url":"https://api.github.com/users/rockfordlhotka/gists{/gist_id}","starred_url":"https://api.github.com/users/rockfordlhotka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rockfordlhotka/subscriptions","organizations_url":"https://api.github.com/users/rockfordlhotka/orgs","repos_url":"https://api.github.com/users/rockfordlhotka/repos","events_url":"https://api.github.com/users/rockfordlhotka/events{/privacy}","received_events_url":"https://api.github.com/users/rockfordlhotka/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":0,"state":"open","created_at":"2015-10-06T03:57:56Z","updated_at":"2015-10-29T16:35:55Z","due_on":"2015-12-31T06:00:00Z","closed_at":null},"comments":3,"created_at":"2015-09-21T21:55:38Z","updated_at":"2015-10-30T00:55:08Z","closed_at":null,"body":"Similar to what was done in #435 for `mscorlib` and `Csla` assemblies, it should be possible to do the same thing for business assemblies.\r\n\r\nArbitrarily creating a unique code would be quite challenging (because the code must always be the same for any given assembly, yet unique across the set of assemblies used by an application). I think we can define an assembly-level attribute that can go into `AssemblyInfo.cs` so the developer can tell us the code to be used.\r\n\r\nOr perhaps a translation map needs to be created at AppDomain initialization. Actually this might be required, as on a data portal server there'd be no way to ensure that any given assembly has been loaded into memory prior to its being needed - and therefore no way to ensure that an arbitrary code can be translated back into an assembly name.\r\n\r\nIn any case, then `MobileFormatter` can be enhanced to translate to that code during serialization and from that code during deserialization."},"comment":{"url":"https://api.github.com/repos/MarimerLLC/csla/issues/comments/152370063","html_url":"https://github.com/MarimerLLC/csla/issues/442#issuecomment-152370063","issue_url":"https://api.github.com/repos/MarimerLLC/csla/issues/442","id":152370063,"user":{"login":"JasonBock","id":904213,"avatar_url":"https://avatars.githubusercontent.com/u/904213?v=3","gravatar_id":"","url":"https://api.github.com/users/JasonBock","html_url":"https://github.com/JasonBock","followers_url":"https://api.github.com/users/JasonBock/followers","following_url":"https://api.github.com/users/JasonBock/following{/other_user}","gists_url":"https://api.github.com/users/JasonBock/gists{/gist_id}","starred_url":"https://api.github.com/users/JasonBock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasonBock/subscriptions","organizations_url":"https://api.github.com/users/JasonBock/orgs","repos_url":"https://api.github.com/users/JasonBock/repos","events_url":"https://api.github.com/users/JasonBock/events{/privacy}","received_events_url":"https://api.github.com/users/JasonBock/received_events","type":"User","site_admin":false},"created_at":"2015-10-30T00:55:08Z","updated_at":"2015-10-30T00:55:08Z","body":"OK, here's my thoughts. I could be way off on this stuff, but ... just think about it :)\r\n\r\nWhen you do deserialization of a type via `MobileFormatter`, keep a running dictionary of assembly names that you've seen before, and map those into unique integers. Put those integers into the `TypeName` property of the `SerializationInfo` to represent the assembly name. Once you have the object serialized, put the dictionary into the stream as well. On deserialization, find the map first, and use that to translate the shortened assembly name into full assembly names.\r\n\r\nHere's pseudocode:\r\n\r\n    // In AssemblyOne...\r\n    public class CustomName\r\n      : BusinessBase<CustomName> { }\r\n\r\n    // In AssemblyTwo...\r\n    public class Data\r\n      : BusinessBase<Data> { }  \r\n\r\n    // In AssemblyThree...  \r\n    public class MyBusinessObject\r\n      : BusinessBase<MyBusinessObject>\r\n    {\r\n      public static readonly IPropertyInfo<CustomName> NameOneProperty = \r\n        RegisterProperty(_ => _.NameOne);\r\n      public CustomName NameOne { get ... set ...}\r\n\r\n      public static readonly IPropertyInfo<CustomName> NameTwoProperty = \r\n        RegisterProperty(_ => _.NameTwo);\r\n      public CustomName NameTwo { get ... set ...}\r\n\r\n      public static readonly IPropertyInfo<Data> ValueProperty = \r\n        RegisterProperty(_ => _.Value);\r\n      public CustomName Value { get ... set ...}\r\n    }\r\n\r\nIf you'd serialize an instance of `MyBusinessObject`, the assembly name map would look something like this:\r\n\r\n1, \"AssemblyThree...\"\r\n2, \"AssemblyOne...\"\r\n3, \"AssemblyTwo...\"\r\n\r\nThe names of the types in the serialization stream would contain these keys, e.g. \"MyBusinessObject, /1\".\r\n\r\nThis should hopefully reduce the size of the stream. You could theoretically do this with the type names as well, which may be helpful with serializing collections of objects."}}