marimerllc / csla Goto Github PK
View Code? Open in Web Editor NEWA home for your business logic in any .NET application.
Home Page: https://cslanet.com
License: MIT License
A home for your business logic in any .NET application.
Home Page: https://cslanet.com
License: MIT License
The build scripts and documentation all refer to svn and need to be updated to reflect the switch to github.
The PropertyInfo
type in Csla.Xaml
is attached to a specific property and it exposes bindable metastate values for that property (CanRead, IsBusy, etc.) for use within XAML data binding.
There should be an equivalent type (probably ObjectInfo
) that can be attached to a business object. This would expose bindable metastate values for the object itself (IsValid, IsSaveable, IsBusy, etc.).
Needs to be implemented for Xamarin Forms, WPF, and UWP.
More info:
http://forums.lhotka.net/forums/t/9895.aspx
This allows the specified task to run and return on pure background threads. Don't use this when the callback really does need to return to the UI (synchronized) thread, but otherwise this should be used to allow free-flowing tasks.
It would be ideal if the language-specific satellite assemblies were part of the installer.
It is tedious to think about manually adding them to the installer, though that's an option I suppose, because we don't add/remove languages very often.
Instead of using TLS and/or HttpContext.Current, ApplicationContext could store its context in the LogicalContext value of ExecutionContext. The .NET framework flows a copy of ExecutionContext onto each thread used as part of the app's logical process flow.
The drawback to this is that ExecutionContext probably doesn't exist on WinRT.
An alternate solution would be to create a dictionary keyed using weak references to Thread and have ApplicationContext lazily copy the master context to a new entry in this dictionary when a new thread is used. This seems complex, but might provide a common implementation across all platforms.
This behaviour was found from csla 4.5.1 from production, i pulled the beta 2 and now in the code from repository.
This code throws exception
DataPortal.Fetch failed (Unable to cast object of type 'App1.SecondCriteria' to type 'App1.Criteria'.)
Imports Csla.Serialization
_
Public Class TestBase
Inherits Csla.BusinessBase(Of TestBase)
End Class
_
Public Class Test
Inherits TestBase
Public Shared Async Function GetTestAsync() As Task(Of Test)
Return Await Csla.DataPortal.FetchAsync(Of Test)(New SecondCriteria)
End Function
Private Overloads Sub DataPortal_Fetch(ByVal p As Criteria)
' Dim ooooo = DocumentControls
End Sub
Private Overloads Sub DataPortal_Fetch(ByVal p As SecondCriteria)
' Dim ooooo = DocumentControls
End Sub
End Class
When installing the latest stable build 4.5.10, the installer places the contents into a local folder named 4.5.4.
In most dev workstations COM+ isn't configured to work anymore, so these tests typically fail. Additionally, COM+ transactions are increasingly rare and the related code hasn't changed in many years, so the risk of not always running these tests is relatively low.
See: http://forums.lhotka.net/forums/p/10918/50864.aspx#50864
The IsValid property of PropertyStatus is set in the UpdateState method
IsValid = BrokenRules.Count == 0;
If following the traditional rules for IsValid on a business object that code line should be:
IsValid = BrokenRules.Any(p => p.Severity == RuleSeverity.Error);
Is it intentional that the IsValid property of PropertyStatus is set to false even if the max error severity is Information or Warning?
And the IsValid has a private setter so even if the developer overrides the UpdateState method there is no means of altering the handling of IsValid.
http://forums.lhotka.net/forums/t/8851.aspx
I would like to suggest the following change to the thrown error in Csla.Reflection.MethodCaller.CallMethod
:
public static object CallMethod(object obj, string method, params object[] parameters)
public static object CallMethod(object obj, MethodInfo info, params object[] parameters)
From: throw new NotImplementedException(method + " " + Resources.MethodNotImplemented
To: throw new NotImplementedException(method + " " + Resources.MethodNotImplemented + " on " + obj.GetType().ToString());
The benefit is that the error messages gives a better clue to what is missing.
Binaries make git sad, so it's best to exclude them unless necessary
Make it easier to test a particular release when it can be checked out by tag name.
http://forums.lhotka.net/forums/t/11789.aspx
Hi Rocky
Since moving over from 4.3 to 4.5 I'm experiencing a strange issue with the Xaml ViewModelBase when calling BeginSave() and the DataPortal throws an exception.
BeginSave works just fine when there is no exception on the server side data portal, however what I'm observing is that if the server side data portal throws an exception the exception is never received. Also, IsBusy stays stuck on true and OnError is never called.
I have a suspicion that the ViewModelBase class was initially a great help to work with the DataPortalResult callback pattern that was used pre-Async pattern.
I'm not sure which is now the preferred way of saving the business object under Silverlight when using the ViewModel and CSLA 4.5 with the Async pattern available.
Do we still call BeginSave() - doesn't this still employ the Callback pattern?
I see there is a new method on the ViewModel called SaveAsync() - this would typically be awaited upon, but then I'm curious what the exception handling strategy with that is, because I'm assuming that the SaveAsync on the ViewModel still sets the Error property and still calls OnError. Would an (aggregate task) exception ever be "returned" then when you call SaveAsync()?
Hopefully this makes some sense - love to get your input.
On a related note, I'm thinking that the following method is "missing" from CSLA ViewModel class:
protected virtual async Task RefreshAsync( Func<Task<T>> factoryMethod )
{
Error = null;
try
{
IsBusy = true;
var model = await factoryMethod();
OnRefreshing( model );
Model = model;
IsBusy = false;
}
catch ( Exception ex )
{
IsBusy = false;
Error = ex;
}
OnRefreshed();
}
In addition to the above, it looks like the issue has to do with the ISupportUndo.Saved event not being raised on the Silverlight client side in the event of an exception being thrown on the server side data portal.
This event is key to the current implementations of the BeginSave() and SaveAsync() methods on the Xaml.ViewModelBase class.
If I override the SaveAsync implementation with an awaited implementation (and not use the Saved event) then the exception reaches back to the Silverlight client. So it might be that the Saved event isn't being called correctly by the DataPortalClient implementation or that the event isn't being serialised correctly.
Here's the override implementation of ViewModelBase.SaveAsync() that fixes the above bug and works quite well. Perhaps this should be the replacement implementation?
protected override async Task<T> SaveAsync()
{
try
{
var savable = Model as Csla.Core.ISavable;
if ( ManageObjectLifetime )
{
// clone the object if possible
var clonable = Model as Csla.ICloneable;
if ( clonable != null )
savable = (Csla.Core.ISavable)clonable.Clone();
//apply changes
var undoable = savable as Csla.Core.ISupportUndo;
if ( undoable != null )
undoable.ApplyEdit();
}
Error = null;
IsBusy = true;
var model = await savable.SaveAsync();
OnSaving( model as T );
Model = (T)model;
IsBusy = false;
OnSaved();
return Model;
}
catch ( Exception ex )
{
IsBusy = false;
Error = ex;
OnSaved();
return null;
}
}
Specifically, it should be possible to create a data map that provides just a single list of string names that are properties to be mapped:
var map = new DataMap(new List<string> { "a", "b", "c" });
LoadProperty/ReadProperty should provide uniform access (or no access) to private properties. This is important for rules (InputProperties/AddOutValue to work properly). Developers should NOT have to handle property type within the rules - it should be handled in the BO.
A: Provide no access to PrivateFields in ReadProperty/LoadProperty. Should rather throw an Exception.
B: Provide access to private fields by expecting code to have Get/Set properties for the field.
ReadProperty (Csla 4.2) provides access to private fields by calling the property getter so alternative A may break existing applications.
Alter data portal to allow T to be an interface type or a concrete type
The data portal could accept interface types for T with some alterations. For example:
var obj = DataPortal.FetchAsync<IPersonEdit>(123); // return an IPersonEdit
To make this happen for the factory data portal models the only immediate change appears to be to allow the ObjectFactory attribute to apply to an interface as well as a class.
To make this happen for the encapsulated data portal models requires more work. Probably need an IDataPortalActivator like this:
public interface IDataPortalActivator
{
Type GetConcreteType(Type requestedType);
object CreateInstance(Type requestedType);
}
The data portal would invoke these interface methods to get type and instance values rather than directly using the type of T as it does now. This will impact the client-side data portal and server-side data portal, because both interact with the concrete type to find the RunLocal and Transactional attributes.
Or perhaps the data portal should look for those attributes on the interface?
In any case, the new CreateInstance method needs to map the interface type (if T is an interface) to an appropriate concrete instance as required by Csla.Server.SimpleDataPortal.
I am using the CSLA 4.5 currently in production
In the code below if i take the
Protected Overloads Sub DataPortal_Fetch(ByVal criteria as DocumentCriteria) method and put in the DocumentBase and call
something like
dim v=await Documen.GetDocumentAsync(new DocumentCriteria), i get exception but if i put the method in the Document Class it works perfectly
_
public class DocumentBase
Inherits Csla.BusinessBase(Of DocumentBase)
public sub new()
end sub
public sub new()
end sub
protected overridable readonly Property TableNameDocument as string
Get
return "Document"
End Get
End Property
#Else
public shared Async function GetDocumentAsync(criteria as DocumentCriteria) as System.Threading.Tasks.Task(Of Document)
return await DataPortal.FetchAsync(of Document)(criteria)
End Function
#Else
friend shared Function GetChildDocument(byval dr as IDataReader) as Document
Return DataPortal.FetchChild(Of Document)(dr)
End Function
#Else
friend shared Function GetDocument(byval dr as IDataReader) as Document
Return DataPortal.Fetch(Of Document)(dr)
End Function
Protected Overrides Sub DataPortal_DeleteSelf()
Me.DataPortal_Delete()
End Sub
Protected Overloads Sub DataPortal_Delete()
End Sub
#Else
protected Overridable sub DoInsertUpDate(byval cm as IDbCommand,Optional ByVal pParent As Object = Nothing)
End Sub
Protected Overrides Sub DataPortal_Insert()
End Sub
Protected Overrides Sub DataPortal_UpDate()
End Sub
protected overridable sub OnDataPortal()
End Sub
end class
'document class
_
public Partial class Document
inherits Core.DocumentBase
private shared _ForceInit as integer
public sub new
_ForceInit=0
End Sub
Protected Overrides Sub OnDeserialized(ByVal context As System.Runtime.Serialization.StreamingContext)
_ForceInit = 1
MyBase.OnDeserialized(context)
End Sub
public sub New
_ForceInit=0
End Sub
Protected Overrides Sub OnDeserialized(ByVal context As System.Runtime.Serialization.StreamingContext)
MyBase.OnDeserialized(context)
_ForceInit = 1
End Sub
#Else
Protected Overloads Sub DataPortal_Fetch(ByVal criteria as DocumentCriteria)
End Sub
End Class
The default language in the US when creating a WinRT project is en-US.
Sadly the WinRT runtime doesn't seem to fall back from en-US to find the en resource.
To overcome this very common problem for US developers the en resource should be copied twice: to en and to en-US in the WinRT project prior to build.
Create two projects specifically targeting MVC 3 and 4, and remove the Csla.Web.Mvc project.
Change Request for CSLA: Provide consolidated interfaces for all core stereotypes
Description: Most of the core stereotypes do not provide a corresponding base interface that is a consolidation of the interfaces the core stereotypes. This makes it hard to loosen the coupling between layers that use the business objects, and a developer has to manually create the consolidated interface themselves. Having that defined in CSLA proper would eliminate that.
Note that CSLA 4.5 has IDataPortal and IBusinessBase, but does not have interfaces for BusinessListBase (IBusinessListBase), CommandBase (ICommandBase), CslaIdentity (ICslaIdentity), CslaPrincipal (ICslaPrincipal), ReadOnlyBase (IReadOnlyBase) and IReadOnlyListBase (IReadOnlyListBase). There may be more core stereotypes that should have consolidated interfaces.
http://forums.lhotka.net/forums/t/11855.aspx
i noted the method in the ManagedObjectBase
protected virtual void LoadProperty(IPropertyInfo propertyInfo, object newValue)
{
var t = this.GetType();
var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var method = t.GetMethods(flags).FirstOrDefault(c => c.Name == "LoadProperty" && c.IsGenericMethod);
var gm = method.MakeGenericMethod(propertyInfo.Type);
var p = new object[] { propertyInfo, newValue };
gm.Invoke(this, p);
}
if i change the method to this , the issue disappears
protected virtual void LoadProperty(IPropertyInfo propertyInfo, object newValue)
{
var t = this.GetType();
//var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var method = t.GetRuntimeMethods().FirstOrDefault(c => c.Name == "LoadProperty" && c.IsGenericMethod);
var gm = method.MakeGenericMethod(propertyInfo.Type);
var p = new object[] { propertyInfo, newValue };
gm.Invoke(this, p);
}
If the full history is migrated over, version branches could be created for people wishing to submit patches for older releases.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.