Beispiel #1
0
        //public Sample() : this(PropBagTypeSafetyMode.AllPropsMustBeRegistered, null) { }

        //public Sample(PropBagTypeSafetyMode typeSafetyMode) : this(typeSafetyMode, null) { }

        public Sample(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator,
                      string fullClassName, IPropFactory propFactory)
            : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName)
        {
            AddProp <object>("PropObject");

            AddProp <string>("PropString");
            SubscribeToPropChanged <string>(GetDelegate <string>("DoWhenStringChanged"), "PropString");
            AddPropNoValue <string>("PropStringCallDoAfter", comparer: EqualityComparer <string> .Default.Equals);
            SubscribeToPropChanged <string>(GetDelegate <string>("DoWhenStringChanged"), "PropStringCallDoAfter");
            AddPropObjComp <string>("PropStringUseRefComp", extraInfo: null);
            SubscribeToPropChanged <string>(GetDelegate <string>("DoWhenStringChanged"), "PropStringUseRefComp");
            AddProp <bool>("PropBool");

            AddProp <int>("PropInt");

            AddProp <TimeSpan>("PropTimeSpan");

            AddProp <Uri>("PropUri");

            AddProp <Lazy <int> >("PropLazyInt");

            AddProp <Nullable <int> >("PropNullableInt", null, null, initialValue: -1);
            SubscribeToPropChanged <Nullable <int> >(GetDelegate <Nullable <int> >("DoWhenNullIntChanged"), "PropNullableInt");
            AddProp <ICollection <int> >("PropICollectionInt");
            SubscribeToPropChanged <ICollection <int> >(GetDelegate <ICollection <int> >("DoWhenICollectionIntChanged"), "PropICollectionInt");
        }
Beispiel #2
0
        static public PerformanceModel Create(PropBagTypeSafetyMode safetyMode, ViewModelFactoryInterface viewModelFactory)
        {
            AutoMapperHelpers ourHelper      = new AutoMapperHelpers();
            IPropFactory      propFactory_V1 = ourHelper.GetNewPropFactory_V1();

            PropModelType propModel = new PropModel
                                      (
                "PerformanceModel",
                "PropBagLib.Tests",
                DeriveFromClassModeEnum.Custom,
                typeof(PerformanceModel),
                propFactory_V1,
                propFactoryType: null,
                propModelCache: null,
                typeSafetyMode: safetyMode,
                deferMethodRefResolution: true,
                requireExplicitInitialValue: true
                                      );

            long generationId = viewModelFactory.PropModelCache.Add(propModel);

            PerformanceModel pmViewModel = new PerformanceModel(propModel, viewModelFactory);

            pmViewModel.AddPropNoStore <int>("PropIntNoStore");
            pmViewModel.AddPropNoStore <string>("PropStringNoStore");
            pmViewModel.AddProp <int>("PropInt");
            pmViewModel.AddProp <string>("PropString");

            pmViewModel.FixProps();

            return(pmViewModel);
        }
Beispiel #3
0
        //public ExtStoreModel() : this(PropBagTypeSafetyMode.AllPropsMustBeRegistered, null) { }

        //public ExtStoreModel(PropBagTypeSafetyMode typeSafetyMode) : this(typeSafetyMode, null) { }

        public ExtStoreModel(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator,
                             IPropFactory propFactory, string fullClassName)
            : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName)
        {
            AddProp <int>("PropInt3");

            AddProp <int>("PropInt4");
        }
Beispiel #4
0
        static public PerformanceDynModel Create(PropBagTypeSafetyMode safetyMode)
        {
            PerformanceDynModel pm = new PerformanceDynModel(safetyMode);

            pm.AddPropNoStore <int>("PropIntNoStore", null, false, null);
            pm.AddPropNoStore <string>("PropStringNoStore", null, false, null);

            return(pm);
        }
Beispiel #5
0
 public DestinationModel1(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator,
                          IPropFactory propFactory, string fullClassName)
     : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName)
 {
     AddProp <int>("Id", null, null, initialValue: 0);
     AddProp <string>("FirstName", null, null, null);
     AddProp <string>("LastName", null, null, null);
     AddProp <string>("CityOfResidence", null, null, null);
     AddProp <Profession>("Profession", null, null, Profession.Default);
 }
Beispiel #6
0
        public PropBagDyn(PropBagTypeSafetyMode typeSafetyMode, AbstractPropFactory thePropFactory)
        {
            if (typeSafetyMode == PropBagTypeSafetyMode.OnlyTypedAccess)
            {
                throw new ApplicationException("OnlyTypedAccess is not supported.");
            }

            propBag = new PubPropBag(typeSafetyMode, thePropFactory);
            InterceptEvents(propBag);
        }
Beispiel #7
0
        public static ReadMissingPropPolicyEnum GetReadMissingPolicy(PropBagTypeSafetyMode typeSafetyMode)
        // Not Allowed if Locked.
        => typeSafetyMode == PropBagTypeSafetyMode.Locked
            ? ReadMissingPropPolicyEnum.NotAllowed

        // Register if either RegisterOnGetLoose or RegisterOnGetSafe
                    : typeSafetyMode == PropBagTypeSafetyMode.RegisterOnGetLoose || typeSafetyMode == PropBagTypeSafetyMode.RegisterOnGetSafe
            ? ReadMissingPropPolicyEnum.Register

        // Otherwise Allowed
            : ReadMissingPropPolicyEnum.Allowed;
 public PerformanceDynModel(PropBagTypeSafetyMode typeSafetyMode, IPropFactory factory) : base(typeSafetyMode, factory)
 {
     AddProp <object>("PropObject");
     AddProp <string>("PropString", null, null, initialValue: "");
     AddPropObjComp <string>("PropStringUseRefComp", extraInfo: null);
     AddProp <bool>("PropBool", null, null, initialValue: false);
     AddProp <int>("PropInt");
     AddProp <TimeSpan>("PropTimeSpan");
     AddProp <Uri>("PropUri");
     AddProp <Lazy <int> >("PropLazyInt");
     AddProp <Nullable <int> >("PropNullableInt", null, null, initialValue: -1);
     AddProp <ICollection <int> >("PropICollectionInt", null, null, initialValue: null);
 }
Beispiel #9
0
        public LooseModel(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator, IPropFactory propFactory)
            : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName: "PropBagLib.Tests.LooseModel")
        {
            AddProp <object>("PropObject");
            AddProp <string>("PropString");
            AddProp <string>("PropString2", null, null, "12");
            AddProp <bool>("PropBool", initialValue: false);
            AddProp <int>("PropInt");
            AddProp <TimeSpan>("PropTimeSpan");
            AddProp <Uri>("PropUri");
            AddProp <Lazy <int> >("PropLazyInt");

            //AddBinding<string>("PropString2", "PropString", FF);
        }
Beispiel #10
0
        }                                     // Disallow use of parameterless constructor.

        public TypeSafePropBagMetaData(string fullClassName, PropBagTypeSafetyMode typeSafetyMode, IPropFactory thePropFactory)
        {
            FullClassName  = fullClassName ?? throw new ArgumentNullException(nameof(fullClassName));
            TypeSafetyMode = typeSafetyMode;
            ThePropFactory = thePropFactory ?? throw new ArgumentNullException(nameof(thePropFactory));

            ReturnDefaultForUndefined = GetReturnDefaultForUndefined(typeSafetyMode);
            AllPropsMustBeRegistered  = GetAllPropsMustBeRegistered(typeSafetyMode);
            OnlyTypedAccess           = GetOnlyTypedAddess(typeSafetyMode);
            ReadMissingPropPolicy     = GetReadMissingPolicy(typeSafetyMode);

            //SetPolicyProperties(typeSafetyMode, out bool allPropsMustBeRegistered, out bool onlyTypedAccess,
            //    out ReadMissingPropPolicyEnum readMissingPropPolicy);
            //AllPropsMustBeRegistered = allPropsMustBeRegistered;
            //OnlyTypedAccess = onlyTypedAccess;
            //ReadMissingPropPolicy = readMissingPropPolicy;
        }
Beispiel #11
0
 public XMLPropModel
 (
     string className,
     string namespaceName,
     DeriveFromClassModeEnum deriveFromClassMode = DeriveFromClassModeEnum.Custom,
     PropBagTypeSafetyMode typeSafetyMode        = PropBagTypeSafetyMode.AllPropsMustBeRegistered,
     bool deferMethodRefResolution    = true,
     bool requireExplicitInitialValue = true
 )
 {
     DeriveFromClassMode         = deriveFromClassMode;
     ClassName                   = className;
     Namespace                   = namespaceName;
     TypeSafetyMode              = typeSafetyMode;
     DeferMethodRefResolution    = deferMethodRefResolution;
     RequireExplicitInitialValue = requireExplicitInitialValue;
     Namespaces                  = new List <string>();
     Props = new List <XMLPropItemModel>();
 }
Beispiel #12
0
        public PerformanceModel(PropBagTypeSafetyMode typeSafetyMode, IPropStoreAccessServiceCreator <UInt32, String> storeCreator, IPropFactory factory, string fullClassName) : base(typeSafetyMode, storeCreator, factory, null)
        {
            AddProp <object>("PropObject");

            AddProp <string>("PropString", null, null, initialValue: "");

            AddPropObjComp <string>("PropStringUseRefComp");

            AddProp <bool>("PropBool", null, null, initialValue: false);

            AddProp <int>("PropInt");

            AddProp <TimeSpan>("PropTimeSpan");

            AddProp <Uri>("PropUri");

            AddProp <Lazy <int> >("PropLazyInt");

            AddProp <Nullable <int> >("PropNullableInt", null, null, initialValue: -1);

            AddProp <ICollection <int> >("PropICollectionInt", null, null, initialValue: null);
        }
Beispiel #13
0
 public DestinationModel5(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator,
                          string fullClassName, IPropFactory propFactory)
     : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName)
 {
     AddProp <Guid>("ProductId", null, null, Guid.NewGuid());
 }
Beispiel #14
0
 internal static PerformanceModel Create(PropBagTypeSafetyMode allPropsMustBeRegistered)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 protected PubPropBag(PropBagTypeSafetyMode typeSafetyMode, ViewModelFactoryInterface viewModelFactory, IPropFactory propFactory, string fullClassName)
     : base(typeSafetyMode, viewModelFactory, propFactory, fullClassName)
 {
 }
Beispiel #16
0
 public static bool GetOnlyTypedAddess(PropBagTypeSafetyMode typeSafetyMode)
 => typeSafetyMode == PropBagTypeSafetyMode.Locked ||
 typeSafetyMode == PropBagTypeSafetyMode.Tight ||
 typeSafetyMode == PropBagTypeSafetyMode.OnlyTypedAccess ||
 typeSafetyMode == PropBagTypeSafetyMode.RegisterOnGetSafe;
Beispiel #17
0
 public static bool GetAllPropsMustBeRegistered(PropBagTypeSafetyMode typeSafetyMode)
 => typeSafetyMode == PropBagTypeSafetyMode.Locked ||
 typeSafetyMode == PropBagTypeSafetyMode.Tight ||
 typeSafetyMode == PropBagTypeSafetyMode.AllPropsMustBeRegistered;
Beispiel #18
0
 // The default value is automatically produced when accessing a value that has been set to undefined,
 // if and only if the TypeSafetyMode is 'None' or 'RegisterOnGetLoose.'.
 public static bool GetReturnDefaultForUndefined(PropBagTypeSafetyMode typeSafetyMode)
 => typeSafetyMode == PropBagTypeSafetyMode.None || typeSafetyMode == PropBagTypeSafetyMode.RegisterOnGetLoose;
Beispiel #19
0
 // Starting with an empty PropItemSet
 public PubPropBag(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator,
                   IPropFactory propFactory)
     : this(typeSafetyMode, storeAccessCreator, propFactory, fullClassName : null)
 {
 }
Beispiel #20
0
 public PubPropBag(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator,
                   IPropFactory propFactory, string fullClassName)
     : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName)
 {
 }
Beispiel #21
0
 public PropBagExperimental(PropBagTypeSafetyMode typeSafetyMode, IPropFactory thePropFactory) : base(typeSafetyMode, thePropFactory)
 {
 }
Beispiel #22
0
 public PropBagExperimental(PropBagTypeSafetyMode typeSafetyMode) : base(typeSafetyMode)
 {
 }
Beispiel #23
0
 public PerformanceModel(PropBagTypeSafetyMode typeSafetyMode, IPropStoreAccessServiceCreator <UInt32, String> storeCreator) : this(typeSafetyMode, storeCreator, null, null)
 {
 }
Beispiel #24
0
        }                                                                                                                                       // Shows that if no default constructor is available, the one that takes a single byte is use.

        //// If it not desirable to provide a public, default, parameterless constructor,
        //// a consructor that takes a single byte can be used instead.
        //// NOTE: Neither of these constructors is required if an instance of this class already exists from the proerty
        //// marked with the PropBagInstanceAttribute.
        //// An instance of this class must be available so that we create an instance of a Action<T,T> delegate.
        //public DtoTestViewModelEmit(byte dummy) : base(dummy) {}

        public DtoTestViewModelEmit(PropBagTypeSafetyMode safetyMode) : base(safetyMode, storeAcessorCreator: null, propFactory: null, fullClassName: null)
        {
        }
 public PerformanceDynModel(PropBagTypeSafetyMode typeSafetyMode) : this(typeSafetyMode, null)
 {
 }