Ejemplo n.º 1
0
        public static void RunTest()
        {
            #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            Core.SetSaveOnErrorPath("GeneratedCode");
            ITypeConfig typeConfig =
                Core.FindOrCreateTypeConfig <IMyData, Implementor>("MyType10");

            typeConfig.SetMemberMap
            (
                nameof(Implementor.TheClass),
                "TheLastName",
                nameof(IMyData.LastName),
                true
            );

            typeConfig.SetMemberMapAllowNonPublic(nameof(Implementor.TheClass), nameof(IMyData.GetFullName));

            typeConfig.ConfigurationCompleted();

            IMyData myData = typeConfig.CreateInstanceOfType <IMyData>();
            myData.FirstName = "Joe";
            myData.LastName  = "Doe";

            Assert.Equal("Joe Doe", myData.GetFullName());
            Core.Save("GeneratedCode");
            #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
        }
Ejemplo n.º 2
0
 public void SetUP()
 {
     array = new MyData <int>();
     array.AddItem(5);
     array.AddItem(6);
     array.AddItem(8);
 }
Ejemplo n.º 3
0
            public static void RunTest()
            {
                Core.SetSaveOnErrorPath("GeneratedCode");

                #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
                IMyData myData = Core.CreateImplementedInstance <IMyData, MyData, WrapperInterface>();
                myData.FirstName = "Joe";
                myData.LastName  = "Doe";

                Assert.Equal("Doe, Joe", myData.GetFullName());

                #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS

                IMyData myData1 = Core.CreateImplementedInstance <IMyData, WrapperInterface1>(); //Core.GetInstanceOfGeneratedType<IMyData>("MyType9");

                myData1.FirstName = "Joe";
                myData1.LastName  = "Doe";

                Core.Save("GeneratedCode");

                Assert.Equal("Doe, Joe", myData1.GetFullName());

                IMyData myData2 = Core.CreateImplementedInstance <IMyData, MyData, WrapperInterface>();

                myData2.FirstName = "Joe";
                myData2.LastName  = "Doe";

                Assert.Equal("Doe, Joe", myData2.GetFullName());
            }
Ejemplo n.º 4
0
            public static void RunTest()
            {
                #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
                ITypeConfig typeConfig =
                    Core.FindOrCreateTypeConfig <IMyData, WrapperInterface>("MyType5");

                typeConfig.AddStaticUtilsClass
                (
                    nameof(StaticMethodsTests.WrapperInterface.TheClass),
                    typeof(MyDataUtils)
                );

                typeConfig.SetAllowNonPublicForAllMembers(nameof(WrapperInterface.TheClass));

                //typeConfig.SetPropMap
                //(
                //    nameof(WrapperInterface.TheClass),
                //    "GetTheFullName",
                //    nameof(IMyData.GetFullName),
                //    true);

                typeConfig.ConfigurationCompleted();

                IMyData myData = Core.GetInstanceOfGeneratedType <IMyData>("MyType5");
                myData.FirstName = "Joe";
                myData.LastName  = "Doe";

                Assert.Equal("Joe Doe", myData.GetFullName());
                #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            ITypeConfig <IMyData, NoClass, WrapperInterface> typeConfig =
                Core.FindOrCreateTypeConfig <IMyData, NoClass, WrapperInterface>("MyType");

            typeConfig.SetMemberMap
            (
                nameof(WrapperInterface.TheClass),
                "TheLastName",
                nameof(IMyData.LastName),
                true
            );

            typeConfig.SetPropMapAllowNonPublic(nameof(WrapperInterface.TheClass), nameof(IMyData.GetFullName));

            typeConfig.ConfigurationCompleted();

            IMyData myData = Core.GetInstanceOfGeneratedType <IMyData>("MyType");
            myData.FirstName = "Joe";
            myData.LastName  = "Doe";

            Console.WriteLine(myData.GetFullName());
            #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            #region CONCRETIZATION SAMPLE
            //MyDataImplementorClass classConcretization =
            //    Core.GetClassConcretization<MyDataImplementorClass>();
            #endregion CONCRETIZATION SAMPLE

            #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            //ITypeConfig<IMyData, MyData, WrapperInterface> typeConfig =
            //    Core.CreateTypeConfig<IMyData, MyData, WrapperInterface>("MyType");

            //typeConfig.ConfigurationCompleted();

            //MyData myData = Core.GetInstanceOfGeneratedType<MyData>("MyType");
            //myData.FirstName = "Joe";
            //myData.LastName = "Doe";

            //Console.WriteLine(myData.GetFullName());
            #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS

            ITypeConfig <IMyData, NoClass, WrapperInterface1> typeConfig1 =
                Core.FindOrCreateTypeConfig <IMyData, WrapperInterface1>("MyType1");

            typeConfig1.ConfigurationCompleted();

            IMyData myData1 = Core.GetInstanceOfGeneratedType <IMyData>("MyType1");

            myData1.FirstName = "Joe";
            myData1.LastName  = "Doe";

            Console.WriteLine(myData1.GetFullName());
        }
Ejemplo n.º 7
0
            public static void RunTest()
            {
                #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
                IMyData myData = Core.CreateImplementedInstance <IMyData, WrapperInterface>();
                myData.FirstName = "Joe";
                myData.LastName  = "Doe";

                Assert.Equal("Joe Doe", myData.GetFullName());
                #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            }
Ejemplo n.º 8
0
        public async Task SetDataAsync(IMyData data, CancellationToken cancellationToken)
        {
            var stateDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <long, string> >(StateDictionaryName);

            using (var tx = this.StateManager.CreateTransaction())
            {
                await stateDictionary.AddOrUpdateAsync(tx, key, data.Data, (k, v) => data.Data);

                await tx.CommitAsync();
            }
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            // saves the generated files in case of a compilation error
            Core.SetSaveOnErrorPath("GeneratedCode");

            // created the ITypeConfig for configuring the IMyData implementation
            // using IWrapper interface
            ITypeConfig <IWrapper> typeConfig = Core.FindOrCreateTypeConfig <IMyData, IWrapper>();

            // sets the GetGreetings method of IMyData
            // interface to MydataImplGet.GreetingImpl implementation
            // the two last type arguments signify the string argument that is
            // passed to the method and the string output argument.
            typeConfig.SetReturningMethodMap <IMyData, MyDataImpl, string, string>
            (
                // specifies the interface method to implement
                (data, inputStr) => data.GetGreeting(inputStr),

                // specifies the wrapper object that used
                // to implement the interface method
                (wrapper) => wrapper.TheDataImpl,

                // specifies the method implementation
                (dataImpl, inputStr) => dataImpl.GetGreetingImpl(inputStr)
            );

            // code is generated
            typeConfig.ConfigurationCompleted();

            // we get the instance of the generated class
            // that implements IMyData interface
            IMyData myData = Core.GetInstanceOfGeneratedType <IMyData>();

            // set the first and last names
            myData.FirstName = "Joe";
            myData.LastName  = "Doe";

            // get the greeting by calling IMyData.GetGreeting method of
            // the interface, passing "Hello" string to it
            string greetingStr = myData.GetGreeting("Hello");

            // Prints the resulting string
            // "Hello Joe Doe!"
            Console.WriteLine(greetingStr);

            // saves the generated code in case of successful
            // completion.
            Core.Save("GeneratedCode");
        }
Ejemplo n.º 10
0
        public static void RunTest()
        {
            Core.SetSaveOnErrorPath("GeneratedCode");

            #region CONCRETIZATION SAMPLE
            //MyDataImplementorClass classConcretization =
            //    Core.Concretize<MyDataImplementorClass>();
            #endregion CONCRETIZATION SAMPLE

            #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            ITypeConfig typeConfig =
                Core.FindOrCreateTypeConfig <IMyData, ImplementorClass>("MyType7");

            typeConfig.ConfigurationCompleted();

            MyData myData = typeConfig.CreateInstanceOfType <MyData>();
            myData.FirstName = "Joe";
            myData.LastName  = "Doe";

            Assert.Equal("Doe, Joe", myData.GetFullName());

            #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS

            ITypeConfig typeConfig1 =
                Core.FindOrCreateTypeConfig <IMyData, WrapperInterface1>("MyType9");

            typeConfig1.ConfigurationCompleted();

            IMyData myData1 = typeConfig1.CreateInstanceOfType <IMyData>();

            myData1.FirstName = "Joe";
            myData1.LastName  = "Doe";

            Core.Save("GeneratedCode");

            Assert.Equal("Doe, Joe", myData1.GetFullName());

            ITypeConfig typeConfig2 =
                Core.FindOrCreateTypeConfig <IMyData, ImplementorClass>();

            typeConfig2.ConfigurationCompleted();

            IMyData myData2 = typeConfig2.CreateInstanceOfType <IMyData>();

            myData2.FirstName = "Joe";
            myData2.LastName  = "Doe";

            Assert.Equal("Doe, Joe", myData2.GetFullName());
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            // ITypeConfig is an interface
            // that can be configured to generate the code
            // for a specific type.
            // The Template Argument IMyData specifies
            // the interface to implement.
            // SecondArgument NoInterface means
            // that there are no wrapper objects.
            ITypeConfig typeConfig =
                Core.FindOrCreateTypeConfig <IMyData, NoInterface>();

            // set up the lambda expression for IMyData.FullName Property
            // implementation
            typeConfig.SetPropGetter <IMyData, string>
            (
                // this expression specified the name
                // of the property to implement
                (data) => data.FullName,

                // this is the property implementation expression:
                // Full
                (data) => data.LastName + ", " + data.FirstName
            );

            // specify that the type configuration is completed
            typeConfig.ConfigurationCompleted();

            // Get an instance of IMyData generated implementation
            // type.
            IMyData myData = Core.GetInstanceOfGeneratedType <IMyData>();

            // set FirstName
            myData.FirstName = "Joe";

            // set LastName
            myData.LastName = "Doe";

            // Print FullName
            Console.WriteLine(myData.FullName);

            // save the Roxy generated project under GeneratedCode folder (within the
            // directory that contains the executable)
            Core.Save("GeneratedCode");
        }
Ejemplo n.º 12
0
            public static void RunTest()
            {
                #region WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
                //ITypeConfig typeConfig =
                //    Core.FindOrCreateTypeConfig<OverridingVirtualsTest.IMyData, OverridingVirtualsTest.MyData, OverridingVirtualsTest.WrapperInterface>("MyType3");

                //typeConfig.SetOverrideVirtual(nameof(MyData.GetFullName), false);

                //typeConfig.ConfigurationCompleted();

                IMyData myData = Core.CreateImplementedInstance <IMyData, MyData, WrapperInterface>();
                //Core.GetInstanceOfGeneratedType<OverridingVirtualsTest.MyData>("MyType3");
                myData.FirstName = "Joe";
                myData.LastName  = "Doe";

                Assert.Equal("Doe, Joe", myData.GetFullName());
                #endregion WRAPPED CLASS CONCRETIZATION WITH INHERITANCE FROM ABSTRACT CLASS
            }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            // saves the generated code on compilation error
            Core.SetSaveOnErrorPath("GeneratedCode");

            // creates the TypeConfig object
            // for IMyData interface to be implemented
            // using IWrapper.TheDataImpl
            ITypeConfig <IWrapper> typeConfig =
                Core.FindOrCreateTypeConfig <IMyData, IWrapper>();

            // completes the configuration,
            // generates the code.
            typeConfig.ConfigurationCompleted();

            // creates the object of generated class that
            // implements IMyData interface
            IMyData myData = Core.GetInstanceOfGeneratedType <IMyData>();

            // sets first and last name
            myData.FirstName = "Joe";
            myData.LastName  = "Doe";

            // calls GetGreeting() method
            string greetingStr1 = myData.GetGreeting();

            // writes "Hello World1"
            Console.WriteLine(greetingStr1);

            // calls GetGreeting("Hello") method
            string greetingStr2 = myData.GetGreeting("Hello");

            // prints "Hello Joe Doe!"
            Console.WriteLine(greetingStr2);

            // saves the generated code in case of
            // successful completion.
            Core.Save("GeneratedCode");
        }
Ejemplo n.º 14
0
 public MyWork(IMyData myData)
 {
     _myData = myData;
 }
Ejemplo n.º 15
0
        private int pointer         = 0;              //keeps track of the current position

        public MyDataIterator(IMyData <T> i)
        {
            aggregate = i;
        }
Ejemplo n.º 16
0
 public HomeController(ILogger <HomeController> logger, IMyData mydate)
 {
     _logger = logger;
     _mydata = mydate;
 }
Ejemplo n.º 17
0
 public MyDataController(IConsole console, IMyData data)
 {
     this._console = console;
     this._data    = data;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// set in state.
 /// </summary>
 /// <param name="count"></param>
 /// <returns></returns>
 Task IMyActor.SetDataAsync(IMyData data, CancellationToken cancellationToken)
 {
     // Requests are not guaranteed to be processed in order nor at most once.
     // The update function here verifies that the incoming count is greater than the current count to preserve order.
     return(this.StateManager.SetStateAsync(stateName, data.Data, cancellationToken));
 }