Coder Social home page Coder Social logo

marimerllc / csla Goto Github PK

View Code? Open in Web Editor NEW
1.2K 1.2K 389.0 274.6 MB

A home for your business logic in any .NET application.

Home Page: https://cslanet.com

License: MIT License

PowerShell 0.63% C# 96.23% HTML 0.76% Batchfile 0.01% Shell 0.01% Vim Snippet 1.75% Visual Basic .NET 0.61% Smalltalk 0.01%
asp-net asp-net-core asp-net-mvc aspnet aspnetcore blazor c-sharp csla maui netstandard uwp web-forms webassembly windows-forms windowsforms winforms wpf xamarin xamarin-forms

csla's People

Contributors

ajj7060 avatar b-higginbotham avatar bowman74 avatar bradrem avatar bradtwurst avatar dapperdanhorvath avatar dazinator avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dotmorten avatar eduardo-micromust avatar freelancingonupwork avatar fuzzbone avatar gillesber avatar inickvel avatar jacojordaan avatar jasonbock avatar jonnybee avatar mbernard avatar oatsoda avatar prodinfo avatar rob-v avatar rockfordlhotka avatar russblair avatar simoncropp avatar stefanossendorf avatar swegele avatar tfreitasleal avatar thecakemonster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csla's Issues

PropertyInfo should have a way to display object level broken rules

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

Add localized satellite assemblies to setup project

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.

Rework ApplicationContext to maintain state in ExecutionContext (or similar)

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.

WINRT dataportal can't call a correct overloaded XYZ dataportal method

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

Ignore COM+ unit tests

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.

Consider change in how PropertyStatus,IsValid is set

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.

Improve exception thrown by MethodCaller.CallMethod

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.

Fix issue with Xaml.ViewModelBase and server-side dataportal exceptions

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;

        }

    } 

Allow easier creation of data map object

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" });

Establish symmetry in non-generic LoadProperty/ReadProperty for private fields

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.

Support IoC/DI in data portal

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.

WIN RT Dataportal can not call overloaded dataportal XYZ method in a business base class

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)

If NETFX_CORE Then

public sub new()
end sub

END IF

IF SILVERLIGHT

public sub new()
end sub

ELSE

protected overridable readonly Property TableNameDocument as string
Get
return "Document"
End Get
End Property

END IF

IF SILVERLIGHT Then

#Else

End If

public shared Async function GetDocumentAsync(criteria as DocumentCriteria) as System.Threading.Tasks.Task(Of Document)
return await DataPortal.FetchAsync(of Document)(criteria)
End Function

If SILVERLIGHT Then

#Else
friend shared Function GetChildDocument(byval dr as IDataReader) as Document
Return DataPortal.FetchChild(Of Document)(dr)
End Function

End If

If SILVERLIGHT Then

#Else
friend shared Function GetDocument(byval dr as IDataReader) as Document
Return DataPortal.Fetch(Of Document)(dr)
End Function

End If

IF SILVERLIGHT Then

Else

Protected Overrides Sub DataPortal_DeleteSelf()
Me.DataPortal_Delete()
End Sub
Protected Overloads Sub DataPortal_Delete()

End Sub

End If

IF SILVERLIGHT Then

#Else
protected Overridable sub DoInsertUpDate(byval cm as IDbCommand,Optional ByVal pParent As Object = Nothing)

End Sub

End If

IF SILVERLIGHT Then

Else

Protected Overrides Sub DataPortal_Insert()

End Sub

End If

IF SILVERLIGHT Then

Else

Protected Overrides Sub DataPortal_UpDate()

End Sub

End If

protected overridable sub OnDataPortal()
End Sub
end class

'document class
_
public Partial class Document
inherits Core.DocumentBase
private shared _ForceInit as integer

IF SILVERLIGHT or NETFX_CORE Then

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

Else

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

End If

IF SILVERLIGHT Then

#Else
Protected Overloads Sub DataPortal_Fetch(ByVal criteria as DocumentCriteria)

End Sub

End If

IF SILVERLIGHT Then

Else

End If

IF SILVERLIGHT Then

Else

End If

IF SILVERLIGHT Then

Else

End If

End Class

Provide consolidated interfaces for all core stereotypes

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.

Fix issue with LoadProperty in CommandBase in WinRT

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);
        }

Migrate full history from SVN

If the full history is migrated over, version branches could be created for people wishing to submit patches for older releases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.