public IActionResult GetSimpleComplexObject()
        {
            SampleObject sampleObject = new SampleObject();

            sampleObject = this.cache.GetHelper <SampleObject>("test1");
            return(View(sampleObject));
        }
        public void TestSampleObjectGetList()
        {
            int count = 0;

            // arrange
            SampleObjectController controller = TestUtils.InitODataControllerForTest(new SampleObjectController(_loggerFactory)) as SampleObjectController;

            // act
            var result = controller.Get() as List <SampleObject>;

            // assert
            Assert.NotNull(result);
            TestUtils.ConsoleLog(_logger, result.ToString());
            TestUtils.ConsoleLog(_logger, result.Count.ToString());
            Assert.True(result.Count > 0);
            SampleObject obj = result.Where(x => x.SampleProperty.Contains("1")).FirstOrDefault();

            Assert.True(obj != null);
            string json = JsonConvert.SerializeObject(obj);

            TestUtils.ConsoleLog(_logger, json);
            count = result.Count;

            Assert.True(count > 0);
        }
Beispiel #3
0
        public void ShouldReturnSampleObjectCollection()
        {
            //Setup
            var sampleObject = new SampleObject
            {
                Id = 1
            };

            var mockObject = new List <SampleObject> {
                sampleObject
            };

            var repository = new Mock <IRepository>();

            repository.Setup(i => i.Select(It.IsAny <SampleObject>())).Returns(mockObject);

            //Act
            var business = new Business(repository.Object);
            var model    = business.Select(sampleObject);

            //Assert
            model.Should().BeEquivalentTo(mockObject, "Not are equals.");

            //Verify
            repository.Verify(i => i.Select(sampleObject), Times.Once(), "ShouldReturnSampleObjectCollection failed.");
        }
        public void DbResultToSampleObjectAllowMissing()
        {
            const string mandatoryField         = "Mandatory";
            const int    expectedMandatoryValue = 890;

            {
                DataTable dt = DatasetGenerator.CreateNewBasicDataTable(
                    new string[] { mandatoryField },
                    new Type[] { typeof(int) });

                using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, expectedMandatoryValue))
                {
                    dr.Read();

                    SampleObject obj = new SampleObject();

                    DbAutoFillHelper.FillObjectFromDataReader(dr, obj);

                    Assert.AreEqual(expectedMandatoryValue, obj.Mandatory);
                }
            }

            {
                DataTable dt = DatasetGenerator.CreateNewBasicDataTable(new string[] { }, new Type[] { });

                using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, new object[] { }))
                {
                    dr.Read();
                    SampleObject obj = new SampleObject();

                    Assert.ThrowsException <MissingFieldException>(() => { DbAutoFillHelper.FillObjectFromDataReader(dr, obj); });
                }
            }
        }
Beispiel #5
0
        public void TestValidate()
        {
            var validator = new Validator <SampleObject>();

            validator.AddTest <string>(x => x.PropertyOne,
                                       y => y.Length == 3,
                                       "Test one");
            validator.AddTest <string>(x => x.PropertyOne,
                                       y => y.StartsWith("f"),
                                       "Test two");

            SampleObject target = new SampleObject()
            {
                PropertyOne = "bar"
            };

            Assert.IsFalse(validator.Validate(target), "Not valid");

            target.PropertyOne = "foo!";

            Assert.IsFalse(validator.Validate(target), "Still not valid");

            target.PropertyOne = "foo";

            Assert.IsTrue(validator.Validate(target), "Is valid");
        }
Beispiel #6
0
 internal SampleObject(int typeIndex, int changeTickIndex, int origAllocTickIndex, SampleObject prev)
 {
     this.typeIndex          = typeIndex;
     this.changeTickIndex    = changeTickIndex;
     this.origAllocTickIndex = origAllocTickIndex;
     this.prev = prev;
 }
Beispiel #7
0
        internal void RecordChange(ulong start, ulong end, int changeTickIndex, int origAllocTickIndex, int typeIndex)
        {
            lastTickIndex = changeTickIndex;
            for (ulong id = start; id < end; id += sampleGrain)
            {
                uint index = (uint)(id >> firstLevelShift);
                while (masterTable.Length <= index)
                {
                    GrowMasterTable();
                }

                SampleObject[] so = masterTable[index];
                if (so == null)
                {
                    so = new SampleObject[secondLevelLength];
                    masterTable[index] = so;
                }
                index = (uint)((id >> secondLevelShift) & (secondLevelLength - 1));
                Debug.Assert(so[index] == null || so[index].changeTickIndex <= changeTickIndex);
                SampleObject prev = so[index];
                if (prev != null && prev.typeIndex == typeIndex && prev.origAllocTickIndex == origAllocTickIndex)
                {
                    // no real change - can happen when loading files where allocation profiling was off
                    // to conserve memory, don't allocate a new sample object in this case
                }
                else
                {
                    so[index] = new SampleObject(typeIndex, changeTickIndex, origAllocTickIndex, prev);
                }
            }
        }
Beispiel #8
0
 internal SampleObjectTable(ReadNewLog readNewLog)
 {
     masterTable     = new SampleObject[initialFirstLevelLength][];
     this.readNewLog = readNewLog;
     lastTickIndex   = 0;
     gcTickList      = null;
 }
Beispiel #9
0
        public int Compare(SampleObject <TMember> x, SampleObject <TMember> y)
        {
            if (ReferenceEquals(x, y))
            {
                return(0);
            }

            if (y is null)
            {
                return(1);
            }

            if (x is null)
            {
                return(-1);
            }

            var compare = _memberComparer.Compare(x.Field, y.Field);

            if (compare != 0)
            {
                return(compare);
            }

            return(_memberComparer.Compare(x.Property, y.Property));
        }
Beispiel #10
0
        public void Syntax_IndexedProperty()
        {
            var obj    = new SampleObject();
            var mirror = Mirror.ForObject(obj);

            var ex = Assert.Throws <MirrorException>(() => { var m = mirror["Item"].MemberInfo; });

            Assert.AreEqual("Could not find a unique matching member 'Item' of type 'MbUnit.Tests.Framework.MirrorTest+SampleObject'.  There were 2 matches out of 2 members with the same name.  Try providing additional information to narrow down the choices.", ex.Message);

            Assert.AreEqual("Item", mirror["Item"].WithSignature(typeof(int)).MemberInfo.Name);
            Assert.AreEqual(1, ((PropertyInfo)mirror["Item"].WithSignature(typeof(int)).MemberInfo).GetIndexParameters().Length);
            Assert.AreEqual("Item", mirror["Item"].WithSignature(typeof(int), typeof(int)).MemberInfo.Name);
            Assert.AreEqual(2, ((PropertyInfo)mirror["Item"].WithSignature(typeof(int), typeof(int)).MemberInfo).GetIndexParameters().Length);

            Assert.AreEqual(8, mirror["Item"][4].Value);
            Assert.AreEqual(28, mirror["Item"][4, 7].Value);

            Assert.AreEqual(8, mirror["Item"][4].ValueAsMirror.Instance);
            Assert.AreEqual(28, mirror["Item"][4, 7].ValueAsMirror.Instance);

            mirror["Item"][4].Value = 2;
            Assert.AreEqual(8, obj.indexerLastSetValue);
            mirror["Item"][4, 7].Value = 2;
            Assert.AreEqual(56, obj.indexerLastSetValue);
        }
Beispiel #11
0
        internal void Tests(
            SampleObject instance,
            Ref <SampleObject> r,
            Ref <SampleObject> second,
            Ref <ISampleObject> ir,
            Ref <UnrelatedObject> unrelated,
            ID id
            )
        {
            GIVEN["an object instance"] = () => instance = new SampleObject {
                ID = id = ID.NewID()
            };
            THEN["it can be assigned to a base ref"] = () => ir = instance;
            WHEN["assigning it to a Ref"]            = () => r = instance;
            THEN["the Ref has its ID"] = () => ID.FromRef(r).Should().Be(instance.ID);

            WHEN["creating a Ref from an ID"]        = () => second = id.ToRef <SampleObject>();
            THEN["the Ref is equal to the original"] = () => second.Should().Be(r);
            THEN["the Ref as the specified ID"]      = () => ID.FromRef(second).Should().Be(id);

            WHEN["downcasting a Ref"]       = () => ir = r.Cast <ISampleObject>();
            THEN["it is equal to original"] = () => ir.Should().Be(r);

            WHEN["upcasting the Ref"]          = () => r = ir.Cast <SampleObject>();
            THEN["it is equal to the orignal"] = () => r.Should().Be(ir);
            AND["its still has the same ID"]   = () => ID.FromRef(r).Should().Be(id);

            GIVEN["a unrelated Ref with the same ID"]             = () => unrelated = id.ToRef <UnrelatedObject>();
            THEN["it is not equal to the orignal"]                = () => unrelated.Should().NotBe(r);
            AND["the original is not equal to the unrelated Ref"] = () => r.Should().NotBe(unrelated);
        }
        public void CreateChildTransactionMode_WithNonLoadableOutParameter()
        {
            ExecuteDelegateInWxeFunction(
                WxeTransactionMode <ClientTransactionFactory> .CreateRoot,
                (parentCtx, parentF) =>
            {
                var subFunction = new DomainObjectParameterTestTransactedFunction(
                    WxeTransactionMode <ClientTransactionFactory> .CreateChildIfParent,
                    (ctx, f) =>
                {
                    f.OutParameter      = SampleObject.NewObject();
                    f.OutParameterArray = new[] { SampleObject.NewObject() };
                },
                    null,
                    null);

                subFunction.SetParentStep(parentF);
                subFunction.Execute(parentCtx);

                var parentTransaction = parentF.Transaction.GetNativeTransaction <ClientTransaction>();
                Assert.That(parentTransaction.IsEnlisted(subFunction.OutParameter), Is.True);
                Assert.That(subFunction.OutParameter.State, Is.EqualTo(StateType.Invalid));
                Assert.That(() => subFunction.OutParameter.EnsureDataAvailable(), Throws.TypeOf <ObjectInvalidException>());

                Assert.That(parentTransaction.IsEnlisted(subFunction.OutParameterArray[0]), Is.True);
                Assert.That(subFunction.OutParameterArray[0].State, Is.EqualTo(StateType.Invalid));
                Assert.That(() => subFunction.OutParameterArray[0].EnsureDataAvailable(), Throws.TypeOf <ObjectInvalidException>());
            });
        }
        public void CreateChildTransactionMode_WithNonLoadableInParameter()
        {
            ExecuteDelegateInWxeFunction(
                WxeTransactionMode <ClientTransactionFactory> .CreateRoot,
                (parentCtx, parentF) =>
            {
                var inParameter = SampleObject.NewObject();
                inParameter.Delete();

                var inParameterArray = new[] { SampleObject.NewObject() };
                inParameterArray[0].Delete();

                var subFunction = new DomainObjectParameterTestTransactedFunction(
                    WxeTransactionMode <ClientTransactionFactory> .CreateChildIfParent,
                    (ctx, f) =>
                {
                    Assert.That(f.InParameter.State, Is.EqualTo(StateType.Invalid));
                    Assert.That(() => f.InParameter.EnsureDataAvailable(), Throws.TypeOf <ObjectInvalidException> ());

                    Assert.That(f.InParameterArray[0].State, Is.EqualTo(StateType.Invalid));
                    Assert.That(() => f.InParameterArray[0].EnsureDataAvailable(), Throws.TypeOf <ObjectInvalidException> ());
                },
                    inParameter,
                    inParameterArray);

                subFunction.SetParentStep(parentF);
                subFunction.Execute(parentCtx);
            });
        }
        public void Replaced_comparable_object_is_compared_with_custom_implementation()
        {
            var comparer = new ComparerBuilder().GetComparer <SampleObject <ComparableBaseObject <EnumSmall> > >();
            var fixture  = FixtureBuilder.GetInstance();

            var one = new SampleObject <ComparableBaseObject <EnumSmall> > {
                Property = fixture.Create <ComparableChildObject <EnumSmall> >()
            };

            comparer.Compare(one, one.DeepClone()).Should().Be(0);

            for (var i = 0; i < Constants.SmallCount; i++)
            {
                one.Property = fixture.Create <ComparableChildObject <EnumSmall> >();
                var other = new SampleObject <ComparableBaseObject <EnumSmall> > {
                    Property = fixture.Create <ComparableChildObject <EnumSmall> >()
                };

                var expected = one.Property.CompareTo(other.Property).Normalize();
                var actual   = comparer.Compare(one, other).Normalize();

                actual.Should().Be(expected);
            }

            ComparableChildObject <EnumSmall> .UsedCompareTo.Should().BeTrue();
        }
Beispiel #15
0
        public void Syntax_InstanceMethod()
        {
            var obj    = new SampleObject();
            var mirror = Mirror.ForObject(obj);

            var ex = Assert.Throws <MirrorException>(() => { var m = mirror["InstanceMethod"].MemberInfo; });

            Assert.AreEqual("Could not find a unique matching member 'InstanceMethod' of type 'MbUnit.Tests.Framework.MirrorTest+SampleObject'.  There were 5 matches out of 5 members with the same name.  Try providing additional information to narrow down the choices.", ex.Message);

            Assert.AreEqual("InstanceMethod", mirror["InstanceMethod"].WithGenericArgs().WithSignature().MemberInfo.Name);
            Assert.AreEqual(0, ((MethodInfo)mirror["InstanceMethod"].WithGenericArgs().WithSignature().MemberInfo).GetParameters().Length);
            Assert.AreEqual("InstanceMethod", mirror["InstanceMethod"].WithGenericArgs().WithSignature(typeof(int)).MemberInfo.Name);
            Assert.AreEqual(1, ((MethodInfo)mirror["InstanceMethod"].WithGenericArgs().WithSignature(typeof(int)).MemberInfo).GetParameters().Length);
            Assert.AreEqual("InstanceMethod", mirror["InstanceMethod"].WithSignature(typeof(int), typeof(int)).MemberInfo.Name);
            Assert.AreEqual(2, ((MethodInfo)mirror["InstanceMethod"].WithSignature(typeof(int), typeof(int)).MemberInfo).GetParameters().Length);
            Assert.AreEqual("InstanceMethod", mirror["InstanceMethod"].WithGenericArgs(typeof(int)).WithSignature().MemberInfo.Name);
            Assert.AreEqual(0, ((MethodInfo)mirror["InstanceMethod"].WithGenericArgs(typeof(int)).WithSignature().MemberInfo).GetParameters().Length);
            Assert.AreEqual("InstanceMethod", mirror["InstanceMethod"].WithGenericArgs(typeof(int)).WithSignature(typeof(int)).MemberInfo.Name);
            Assert.AreEqual(1, ((MethodInfo)mirror["InstanceMethod"].WithGenericArgs(typeof(int)).WithSignature(typeof(int)).MemberInfo).GetParameters().Length);

            Assert.AreEqual(5, mirror["InstanceMethod"].WithGenericArgs().Invoke());
            Assert.AreEqual(8, mirror["InstanceMethod"].WithGenericArgs().Invoke(4));
            Assert.AreEqual(28, mirror["InstanceMethod"].Invoke(4, 7));
            Assert.AreEqual(0, mirror["InstanceMethod"].WithGenericArgs(typeof(int)).Invoke());
            Assert.AreEqual(4, mirror["InstanceMethod"].WithGenericArgs(typeof(int)).Invoke(4));
        }
Beispiel #16
0
        public void TestValidateResults()
        {
            var validator = new Validator <SampleObject>();
            ValidationTestList <SampleObject> list;

            validator.AddTest <string>(x => x.PropertyOne,
                                       y => y.Length == 3,
                                       "Test one");
            validator.AddTest <string>(x => x.PropertyOne,
                                       y => y.StartsWith("f"),
                                       "Test two");

            SampleObject target = new SampleObject()
            {
                PropertyOne = "bar"
            };

            Assert.IsFalse(validator.Validate(target, out list), "Not valid");
            Assert.AreEqual(1, list.Count, "Correct count of failures (1)");
            Assert.AreEqual("Test two", list[0].Identifier, "Correct identifier (1)");

            target.PropertyOne = "foo!";

            Assert.IsFalse(validator.Validate(target, out list), "Still not valid");
            Assert.AreEqual(1, list.Count, "Correct count of failures (2)");
            Assert.AreEqual("Test one", list[0].Identifier, "Correct identifier (2)");

            target.PropertyOne = "foo";

            Assert.IsTrue(validator.Validate(target, out list), "Is valid");
            Assert.AreEqual(0, list.Count, "Correct count of failures (3)");
        }
Beispiel #17
0
 public DomainObjectParameterTestTransactedFunction(
     ITransactionMode transactionMode,
     Action <WxeContext, DomainObjectParameterTestTransactedFunction> testDelegate,
     SampleObject inParameter,
     SampleObject[] inParameterArray)
     : base(transactionMode, (ctx, f) => testDelegate(ctx, (DomainObjectParameterTestTransactedFunction)f), inParameter, inParameterArray)
 {
 }
 void PrintSampleObjectFields(SampleObject s)
 {
     log  = "Received SampleObject: \n";
     log += "ObjName: " + s.ObjectName + "\n";
     log += "another string" + s.SampleString + "\n";
     log += "Sample int" + s.SampleInt + "\n";
     log += "Sample float: " + s.SampleFloat;
 }
        public void End()
        {
            var state        = new MockSampleState();
            var sampleObject = new SampleObject(state);

            sampleObject.End();

            state.VerifyEndCalled();
        }
Beispiel #20
0
        public SampleContext(ISerializer serializer, IDataStorage dataStorage) : base(serializer, dataStorage)
        {
            typedSet = GetOrCreateObjectSet <SampleObject>("SampleObjects");
            o1       = typedSet.GetOrCreate("oid1");
            o2       = typedSet.GetOrCreate("oid2");

            untypedSet = GetOrCreateObjectSet("untyped");
            ononotify  = untypedSet.GetOrCreate <SampleObjectWithNotifyError>("ononotify");
        }
        public void CreateChildTransactionMode_InAndOutParametersCanBeUsed()
        {
            ExecuteDelegateInWxeFunction(
                WxeTransactionMode <ClientTransactionFactory> .CreateRoot,
                (parentCtx, parentF) =>
            {
                var inParameter                   = SampleObject.NewObject();
                var inParameterArray              = new[] { SampleObject.NewObject() };
                inParameter.Int32Property         = 7;
                inParameterArray[0].Int32Property = 8;

                var parentTransaction = parentF.Transaction.GetNativeTransaction <ClientTransaction> ();

                var subFunction = new DomainObjectParameterTestTransactedFunction(
                    WxeTransactionMode <ClientTransactionFactory> .CreateChildIfParent,
                    (ctx, f) =>
                {
                    var clientTransaction = f.Transaction.GetNativeTransaction <ClientTransaction> ();
                    Assert.That(clientTransaction, Is.Not.Null.And.SameAs(ClientTransaction.Current));
                    Assert.That(clientTransaction, Is.Not.SameAs(parentTransaction));
                    Assert.That(clientTransaction.ParentTransaction, Is.SameAs(parentTransaction));

                    Assert.That(clientTransaction.IsEnlisted(f.InParameter), Is.True);
                    Assert.That(clientTransaction.IsEnlisted(f.InParameterArray[0]));

                    // Since this function is running in a subtransaction, the properties set in the parent transaction are visible from here.
                    Assert.That(f.InParameter.Int32Property, Is.EqualTo(7));
                    Assert.That(f.InParameterArray[0].Int32Property, Is.EqualTo(8));

                    // Since this function is running in a subtransaction, out parameters are visible within the parent function if the transaction is
                    // committed.
                    f.OutParameter = SampleObject.NewObject();
                    f.OutParameter.Int32Property         = 17;
                    f.OutParameterArray                  = new[] { SampleObject.NewObject(), SampleObject.NewObject() };
                    f.OutParameterArray[0].Int32Property = 4;

                    ClientTransaction.Current.Commit();

                    f.OutParameterArray[1].Int32Property = 5;
                },
                    inParameter,
                    inParameterArray);

                subFunction.SetParentStep(parentF);
                subFunction.Execute(parentCtx);

                var outParameter      = subFunction.OutParameter;
                var outParameterArray = subFunction.OutParameterArray;

                Assert.That(parentTransaction.IsEnlisted(outParameter), Is.True);
                Assert.That(outParameter.Int32Property, Is.EqualTo(17));
                Assert.That(parentTransaction.IsEnlisted(outParameterArray[0]), Is.True);
                Assert.That(outParameterArray[0].Int32Property, Is.EqualTo(4));
                Assert.That(parentTransaction.IsEnlisted(outParameterArray[1]), Is.True);
                Assert.That(outParameterArray[1].Int32Property, Is.Not.EqualTo(4));
            });
        }
        private int GetInt32Property(ClientTransaction clientTransaction)
        {
            using (clientTransaction.EnterDiscardingScope())
            {
                SampleObject objectWithAllDataTypes = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <SampleObject> ();

                return(objectWithAllDataTypes.Int32Property);
            }
        }
 public void Run()
 {
     dynamic obj = new SampleObject();
     obj.SomeProperty = "test";
     obj.AnotherProperty = 67;
     Console.WriteLine(obj.SomeProperty);
     Console.WriteLine(obj.AnotherProperty);
     Console.WriteLine((string)obj.PropertyThatDoesNotExist);
 }
        public void Start()
        {
            var state        = new MockSampleState();
            var sampleObject = new SampleObject(state);

            sampleObject.Start();

            state.VerifyStartCalled();
        }
        public void Middle()
        {
            var state        = new MockSampleState();
            var sampleObject = new SampleObject(state);

            sampleObject.Middle();

            state.VerifyMiddleCalled();
        }
        public void Last()
        {
            var state        = new MockSampleState();
            var sampleObject = new SampleObject(state);

            sampleObject.Last();

            state.VerifyLastCalled();
        }
Beispiel #27
0
        public void SerializeToArrayLessTimes()
        {
            var obj = new SampleObject();

            for (var i = 0; i < 3; i++)
            {
                MessagePackSerializer.Serialize(obj);
            }
        }
Beispiel #28
0
 public IEnumerable <SampleObject> Select(SampleObject obj)
 {
     return(new List <SampleObject>
     {
         new SampleObject {
             Id = 1
         }
     });
 }
Beispiel #29
0
        public static void RunMain()
        {
            dynamic obj = new SampleObject();

            Console.WriteLine(obj.SomeProperty);

            Console.Write("Press a key to exit");
            Console.ReadKey();
        }
Beispiel #30
0
        private void GrowMasterTable()
        {
            SampleObject[][] newMasterTable = new SampleObject[masterTable.Length * 2][];
            for (int i = 0; i < masterTable.Length; i++)
            {
                newMasterTable[i] = masterTable[i];
            }

            masterTable = newMasterTable;
        }
Beispiel #31
0
        public async Task <SampleObject> InsertSampleObjectAsync(SampleObject sampleObject)
        {
            var entity = _mapper.Map <SampleObjectEntity>(sampleObject);

            TableOperation insertOperation = TableOperation.Insert(entity);

            await _table.ExecuteAsync(insertOperation);

            return(sampleObject);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        SampleObject Object1 = new SampleObject();
        Object1.Id = 1;
        Object1.Name = "Object1";
        Object1.Desc = "This is a sample object.";

        string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Object1);

        Response.Write("<strong>Serialized Object:</strong> <br />" + json);
    }
Beispiel #33
0
 internal void RecordChange(ulong start, ulong end, int changeTickIndex, int origAllocTickIndex, int typeIndex)
 {
     lastTickIndex = changeTickIndex;
     for (ulong id = start; id < end; id += sampleGrain)
     {
         uint index = (uint)(id >> firstLevelShift);
         while (masterTable.Length < index)
             GrowMasterTable();
         SampleObject[] so = masterTable[index];
         if (so == null)
         {
             so = new SampleObject[secondLevelLength];
             masterTable[index] = so;
         }
         index = (uint)((id >> secondLevelShift) & (secondLevelLength-1));
         Debug.Assert(so[index] == null || so[index].changeTickIndex <= changeTickIndex);
         SampleObject prev = so[index];
         if (prev != null && prev.typeIndex == typeIndex && prev.origAllocTickIndex == origAllocTickIndex)
         {
             // no real change - can happen when loading files where allocation profiling was off
             // to conserve memory, don't allocate a new sample object in this case
         }
         else
         {
             so[index] = new SampleObject(typeIndex, changeTickIndex, origAllocTickIndex, prev);
         }
     }
 }
Beispiel #34
0
 internal SampleObjectTable(ReadNewLog readNewLog)
 {
     masterTable = new SampleObject[initialFirstLevelLength][];
     this.readNewLog = readNewLog;
     lastTickIndex = 0;
     gcTickList = null;
 }
Beispiel #35
0
 void GrowMasterTable()
 {
     SampleObject[][] newMasterTable = new SampleObject[masterTable.Length * 2][];
     for (int i = 0; i < masterTable.Length; i++)
         newMasterTable[i] = masterTable[i];
     masterTable = newMasterTable;
 }
Beispiel #36
0
 internal SampleObject(int typeIndex, int changeTickIndex, int origAllocTickIndex, SampleObject prev)
 {
     this.typeIndex = typeIndex;
     this.changeTickIndex = changeTickIndex;
     this.origAllocTickIndex = origAllocTickIndex;
     this.prev = prev;
 }
Beispiel #37
0
        internal void AddGcTick(int tickIndex, int gen)
        {
            lastTickIndex = tickIndex;

            gcTickList = new SampleObject(gen, tickIndex, 0, gcTickList);
        }
 public ActionResult SomeOtherMethod(int number, SampleObject obj)
 {
     return View();
 }
 public void Run()
 {
     dynamic obj = new SampleObject();
     Console.WriteLine(obj.SomeProperty);
 }
Beispiel #40
0
        public static void Main(string[] Args)
        {
            if (Args.Length > 0)
            {
                if (Args[0] == "spawnclient")
                {
                    NamedPipeClientStream pipeClient =
                        new NamedPipeClientStream(".", "testpipe",
                            PipeDirection.InOut, PipeOptions.None,
                            TokenImpersonationLevel.Impersonation);

                    Console.WriteLine("Connecting to server...\n");
                    pipeClient.Connect();
                    SampleModel.SampleObject obj = new SampleObject() { PDFURL = "star" };
                    BinaryFormatter bf = new BinaryFormatter();

                    using (MemoryStream ms = new MemoryStream())
                    {
                        bf.Serialize(ms, obj);
                        pipeClient.WriteByte(ms.ToArray());
                        //pipeClient.Write(, 0, ms.ToArray().Length);

                    }

                    //StreamWriter sw = new StreamWriter(pipeClient);
                    //sw.WriteLine("시작");
                    //sw.Flush();
                    //StreamString ss = new StreamString(pipeClient);
                    //// Validate the server's signature string
                    //if (ss.ReadString() == "I am the one true server!")
                    //{
                    //    // The client security token is sent with the first write.
                    //    // Send the name of the file whose contents are returned
                    //    // by the server.
                    //    ss.WriteString("c:\\textfile.txt");

                    //    // Print the file to the screen.
                    //    Console.Write(ss.ReadString());
                    //}
                    //else
                    //{
                    //    Console.WriteLine("Server could not be verified.");
                    //}
                    //pipeClient.Close();
                    // Give the client process some time to display results before exiting.

                    Thread.Sleep(4000);
                    pipeClient.Close();
                }
            }
            else
            {
                Console.WriteLine("\n*** Named pipe client stream with impersonation example ***\n");
                StartClients();
            }
        }