private void Insert(ref SomeType current, SomeType newItem)
 {
     if (current == null)
     {
         current = newItem;
     }
 }
        private void CallVirt()
        {
            SomeType val = new SomeType();

            // callvirt  instance void Type.MethodRunner/BaseType::MethodVirtual()
            val.MethodVirtual();
        }
Beispiel #3
0
        public void StoreWithProtoTranscoder()
        {
            var config     = GetConfig();
            var transcoder = new AqlaSerializer.Caching.Enyim.NetTranscoder();

            config.Transcoder = transcoder;
            SomeType obj = new SomeType {
                Id = 1, Name = "abc"
            }, clone;
            string cloneString;

            Assert.AreEqual(0, transcoder.Deserialized);
            Assert.AreEqual(0, transcoder.Serialized);
            using (var client = new MemcachedClient(config))
            {
                client.Store(StoreMode.Set, "raw1", obj);
                client.Store(StoreMode.Set, "raw2", "def");
            }
            Assert.AreEqual(0, transcoder.Deserialized);
            Assert.AreEqual(1, transcoder.Serialized);
            using (var client = new MemcachedClient(config))
            {
                clone       = (SomeType)client.Get("raw1");
                cloneString = (string)client.Get("raw2");
            }
            Assert.AreEqual(1, transcoder.Deserialized);
            Assert.AreEqual(1, transcoder.Serialized);

            Assert.AreEqual(1, clone.Id);
            Assert.AreEqual("abc", clone.Name);
            Assert.AreEqual("def", cloneString);
        }
Beispiel #4
0
 public RegistrationLoggingBehavior(
     IContainer container,
     IBehaviorChain behaviorChainChain, Logger logger,
     HttpRequestMessage requestMessage,
     HttpResponseMessage responseMessage,
     HttpResponseHeaders responseHeaders,
     HttpConfiguration httpConfiguration,
     HttpRequestContext httpRequestContext,
     ActionDescriptor actionDescriptor,
     ActionMethod actionMethod,
     RouteDescriptor routeDescriptor,
     RequestCancellation requestCancellation,
     UrlParameters urlParameters,
     QuerystringParameters querystringParameters,
     SomeType someInstance)
 {
     BehaviorChain = behaviorChainChain;
     logger.Write(container);
     logger.Write(requestMessage);
     logger.Write(responseMessage);
     logger.Write(responseHeaders);
     logger.Write(actionMethod);
     logger.Write(actionDescriptor);
     logger.Write(routeDescriptor);
     logger.Write(httpRequestContext);
     logger.Write(httpConfiguration);
     logger.Write(requestCancellation);
     logger.Write(urlParameters);
     logger.Write(querystringParameters);
     logger.Write(someInstance);
 }
Beispiel #5
0
    private static void Main(string[] args)
    {
        var g = new Generic <SomeType>();
        var s = new SomeType();

        g.bsPro(s);
    }
 public static void SomeMethodSafe(this SomeType t)
 {
     if (t != null)
     {
         t.SomeMethod();
     }
 }
        private void CallMethod()
        {
            // callvirt  instance void Type.MethodRunner/SomeType::Method()
            var val = new SomeType();

            val.Method();
        }
Beispiel #8
0
 public void TryDoSomething()
 {
     if (SomeType != null)
     {
         SomeType.DoSomething();
     }
 }
    public IActionResult CreateOrUpdate([FromBody] SomeType type)
    {
        try
        {
            // using CreateOrUpdate method makes it necessary to check for existance
            SomeType checkIfExists = _repo.GetById(type.id);

            if (checkIfExists != null)
            {
                // Do some stuff with object
                // ...
                _repo.CreateOrupdate(checkIfExists);
            }
            else
            {
                checkIfExists = new SomeType();
                // Do some stuff
                _repo.CreateOrupdate(checkIfExists);
            }
            _repo.SaveChanges();
            return(StatusCode(201));
        }
        catch (Exception ex)
        {
            return(StatusCode(500, "Internal Server Error"));
        }
    }
Beispiel #10
0
 public SourceType(string name, int id, bool isActive, SomeType title)
 {
     Name     = name;
     Id       = id;
     Title    = title;
     IsActive = isActive;
 }
Beispiel #11
0
        public void can_map_a_resolved_type()
        {
            // given

            var builder = new ContainerBuilder();

            var someInstance = new SomeType();

            BuildRegistration.Instance(someInstance)
            .Select(someType => new SomeTypeWrapper {
                SomeType = someType
            })
            .RegisterIn(builder);

            using (var container = builder.Build())
            {
                // when

                var result = container.Resolve <SomeTypeWrapper>();

                // then

                result.SomeType.Should().BeSameAs(someInstance);
            }
        }
Beispiel #12
0
        public void StoreWithProtoTranscoder()
        {
            var config = GetConfig();
            var transcoder = new ProtoBuf.Caching.Enyim.NetTranscoder();
            config.Transcoder =  transcoder;
            SomeType obj = new SomeType { Id = 1, Name = "abc" }, clone;
            string cloneString;
            Assert.AreEqual(0, transcoder.Deserialized);
            Assert.AreEqual(0, transcoder.Serialized);
            using (var client = new MemcachedClient(config))
            {
                client.Store(StoreMode.Set, "raw1", obj);
                client.Store(StoreMode.Set, "raw2", "def");
            }
            Assert.AreEqual(0, transcoder.Deserialized);
            Assert.AreEqual(1, transcoder.Serialized);
            using (var client = new MemcachedClient(config))
            {
                clone = (SomeType)client.Get("raw1");
                cloneString = (string)client.Get("raw2");
            }
            Assert.AreEqual(1, transcoder.Deserialized);
            Assert.AreEqual(1, transcoder.Serialized);

            Assert.AreEqual(1, clone.Id);
            Assert.AreEqual("abc", clone.Name);
            Assert.AreEqual("def", cloneString);
        }
Beispiel #13
0
    static void Main()
    {
        //<snippet2>
        // Create an instance of the StringBuilder type using
        // Activator.CreateInstance.
        Object o = Activator.CreateInstance(typeof(StringBuilder));

        // Append a string into the StringBuilder object and display the
        // StringBuilder.
        StringBuilder sb = (StringBuilder)o;

        sb.Append("Hello, there.");
        Console.WriteLine(sb);
        //</snippet2>

        //<snippet3>
        // Create an instance of the SomeType class that is defined in this
        // assembly.
        System.Runtime.Remoting.ObjectHandle oh =
            Activator.CreateInstanceFrom(Assembly.GetEntryAssembly().CodeBase,
                                         typeof(SomeType).FullName);

        // Call an instance method defined by the SomeType type using this object.
        SomeType st = (SomeType)oh.Unwrap();

        st.DoSomething(5);
        //</snippet3>
    }
Beispiel #14
0
        public void LogInfo_customType_SendsMessage()
        {
            // Arrange
            var fakeConnectionFactory = new FakeConnectionFactory();
            var appender = GetAppender(fakeConnectionFactory);

            BasicConfigurator.Configure(appender);

            var logger = LogManager.GetLogger(this.GetType());

            // Act
            var item = new SomeType {
                Id = 1, Name = "My Name", UsedAt = new DateTime(2015, 2, 10)
            };

            logger.Info(item);

            Thread.Sleep(2000);

            // Assert
            var publishedMessages = fakeConnectionFactory.UnderlyingModel.PublishedMessagesOnExchange("logging.test");

            Assert.That(publishedMessages, Has.Count.EqualTo(1));

            var messageBody = Encoding.UTF8.GetString(publishedMessages.First().body);

            Assert.That(messageBody, Is.EqualTo("{\"Id\":1,\"Name\":\"My Name\",\"UsedAt\":\"2015-02-10T00:00:00\"}"));
        }
Beispiel #15
0
 public DestinationType(string name, long id, bool isNotActive, SomeType title)
 {
     Name        = name;
     Id          = id;
     Title       = title;
     IsNotActive = isNotActive;
 }
    static void Main()
    {
        var obj = new MyData
        {
            Site = new BasicSite {
                BaseHost = "http://somesite.org"
            },
            Items =
            {
                { "key 1", SomeType.Create(123)   },
                { "key 2", SomeType.Create("abc") },
                { "key 3", SomeType.Create(new Whatever {
                        Id = 456, Name = "def"
                    }) },
            }
        };

        var clone = Serializer.DeepClone(obj);

        Console.WriteLine($"Site: {clone.Site}");
        foreach (var pair in clone.Items)
        {
            Console.WriteLine($"{pair.Key} = {pair.Value}");
        }
    }
        // POST api/musterija
        public bool Post([FromBody] Musterija korisnik)
        {
            foreach (Musterija kor in Musterije.musterije.Values)
            {
                if (kor.KorisnickoIme == korisnik.KorisnickoIme)
                {
                    return(false);
                }
            }
            foreach (Vozac kor in Vozaci.vozaci.Values)
            {
                if (kor.KorisnickoIme == korisnik.KorisnickoIme)
                {
                    return(false);
                }
            }

            foreach (Dispecer kor in Dispeceri.dispeceri.Values)
            {
                if (kor.KorisnickoIme == korisnik.KorisnickoIme)
                {
                    return(false);
                }
            }

            Musterije.musterije = new Dictionary <int, Musterija>();
            SomeType s = new SomeType();

            korisnik.Id    = s.GetHashCode();
            korisnik.Uloga = Enums.Uloga.Musterija;
            Musterije.musterije.Add(korisnik.Id, korisnik);
            UpisTxt(korisnik);
            return(true);
        }
Beispiel #18
0
        private static void Declarations()
        {
            //<IntDeclaration>
            int[] array = new int[5];
            //</IntDeclaration>

            //<StringDeclaration>
            string[] stringArray = new string[6];
            //</StringDeclaration>

            // Declare and set array element values
            //<IntInitialization>
            int[] array1 = new int[] { 1, 3, 5, 7, 9 };
            //</IntInitialization>

            // <StringInitialization>
            string[] weekDays = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
            // </StringInitialization>

            //<ShorthandInitialization>
            int[]    array2    = { 1, 3, 5, 7, 9 };
            string[] weekDays2 = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
            //</ShorthandInitialization>

            //<DeclareAllocate>
            int[] array3;
            array3 = new int[] { 1, 3, 5, 7, 9 };   // OK
            //array3 = {1, 3, 5, 7, 9};   // Error
            //</DeclareAllocate>

            //<FinalInstantiation>
            SomeType[] array4 = new SomeType[10];
            //</FinalInstantiation>
        }
 // ... take SomeTypeFactory as a dependency and save it
 public void AfunctionThatCreatesSomeTypeDynamically()
 {
     using (var wrapper = this.someTypeFactory.Create())
     {
         SomeType subject = wrapper.Subject;
         // ... do stuff
     }
 }
    static void Main()
    {
        var someType = new SomeType();

        someType.Foo = "foo";
        someType.Bar = "bar";
        Debugger.Break();
    }
    public void ProcessWidget(Widget w, Application app)
    {
        //uses an App to work some magic on C
        //app must be called from the original thread that called ExecuteCommand()
        SomeType someData = null;

        hostContext.Send(delegate { someData = app.SomeMethod(); }, null);
    }
Beispiel #22
0
        static void Main(string[] args)
        {
            SomeType oneType = new SomeType();

            oneType.setValue(10, "red");
            oneType.getValue();
            Console.ReadLine();
        }
 public static void WriteWithMarker(this TextWriter writer, SomeType value)
 {
     writer.Write(value);
     if (ExclamationIsSet)
     {
         writer.Write(SomeExtraStuff);
     }
 }
Beispiel #24
0
        // POST api/musterija
        public bool Post([FromBody] Musterija korisnik)
        {
            if (String.IsNullOrEmpty(korisnik.KorisnickoIme) || String.IsNullOrEmpty(korisnik.Lozinka) ||
                String.IsNullOrEmpty(korisnik.Ime) || String.IsNullOrEmpty(korisnik.Prezime) ||
                String.IsNullOrEmpty((korisnik.Pol).ToString()) || String.IsNullOrEmpty(korisnik.JMBG) ||
                String.IsNullOrEmpty(korisnik.KontaktTelefon) || String.IsNullOrEmpty(korisnik.Email))
            {
                return(false);
            }


            Regex r1 = new Regex("[0-9a-zA-Z]{3,}"); //korisnicko ime
            Regex r2 = new Regex("[0-9a-zA-Z]{4,}"); //lozinka
            Regex r3 = new Regex("[0-9]{13}");       //jmbg
            Regex r4 = new Regex("[0-9]{6,14}");     //kontakt
            Regex r5 = new Regex("[a-zA-Z]{2,}");    //ime i prezime



            if (!r1.IsMatch(korisnik.KorisnickoIme) || !r2.IsMatch(korisnik.Lozinka) || !r3.IsMatch(korisnik.JMBG) || !r4.IsMatch(korisnik.KontaktTelefon) || !r5.IsMatch(korisnik.Ime))
            {
                return(false);
            }



            foreach (Musterija kor in Musterije.musterije.Values)
            {
                if (kor.KorisnickoIme == korisnik.KorisnickoIme)
                {
                    return(false);
                }
            }
            foreach (Vozac kor in Vozaci.vozaci.Values)
            {
                if (kor.KorisnickoIme == korisnik.KorisnickoIme)
                {
                    return(false);
                }
            }

            foreach (Dispecer kor in Dispeceri.dispeceri.Values)
            {
                if (kor.KorisnickoIme == korisnik.KorisnickoIme)
                {
                    return(false);
                }
            }

            Musterije.musterije = new Dictionary <int, Musterija>();
            SomeType s = new SomeType();

            korisnik.Id    = s.GetHashCode();
            korisnik.Uloga = Enums.Uloga.Musterija;
            Musterije.musterije.Add(korisnik.Id, korisnik);
            UpisTxt(korisnik);
            return(true);
        }
        private static ICustomAttributeProvider GetProviderStub(SomeType attribute = null)
        {
            object[] attributes = attribute != null ? new object[] {attribute} : new object[] {};

            Mock<ICustomAttributeProvider> providerStub = new Mock<ICustomAttributeProvider>();
            providerStub.Setup(p => p.GetCustomAttributes(It.IsAny<Type>(), It.IsAny<bool>()))
                        .Returns(attributes);
            return providerStub.Object;
        }
Beispiel #26
0
		public void TestChild4()
		{
			_writer.WriteAttribute("Stuff", new SomeType {Value = "Important Stuff!"});
			var reader = CloseAndRead();

			var child = new SomeType();
			reader.TryReadAttribute("Stuff", child).Should().BeTrue();
			child.Value.Should().Be("Important Stuff!");
		}
 public static void RunMain()
 {
     for (int i = 0; i < 15; i++)
     {
         var v = new SomeType();
         GC.Collect();
     }
     Console.ReadKey();
 }
Beispiel #28
0
    public static void Main(String[] args)
    {
        //Console.WriteLine(SomeType.i);
        //Console.WriteLine(SomeType.i);

        SomeType st2 = new SomeType();

        SomeType st1 = new SomeType();
    }
Beispiel #29
0
        private static ICustomAttributeProvider GetProviderStub(SomeType attribute = null)
        {
            object[] attributes = attribute != null ? new object[] { attribute } : new object[] {};

            Mock <ICustomAttributeProvider> providerStub = new Mock <ICustomAttributeProvider>();

            providerStub.Setup(p => p.GetCustomAttributes(It.IsAny <Type>(), It.IsAny <bool>()))
            .Returns(attributes);
            return(providerStub.Object);
        }
        static void Main(string[] args)
        {
            SomeType s = null;

            //s = new SomeType();
            // uncomment me to try it with an instance
            s.SomeMethodSafe();
            Console.WriteLine("Done");
            Console.ReadLine();
        }
        protected override void RunCore()
        {
            var val = new SomeType();

            /* 0x000007CC 7215010070   */
            // IL_0008: ldstr     "asfasdf"
            /* 0x000007D1 7D0D000004   */
            // IL_000D: stfld     string Type.FieldRunner / SomeType::Field2
            val.Field2 = SomeType.Field1; // Field1 is a constant
        }
Beispiel #32
0
 static ALlAcess()
 {
     if (somecondition)
     {
         var1 = x;
     }
     else
     {
         var1 = y;
     }
 }
        public void Arrange()
        {
            _expectedResult = new SomeType();
            _query = new Mock<IQuery<SomeType>>();
            _query.Setup(q => q.Fetch()).Returns(_expectedResult);
            _serviceLocator = new Mock<IQueryLocator>();
            _serviceLocator
                .Setup(l => l.Resolve<SomeType>())
                .Returns(_query.Object);

            _sut = new DataGetter(_serviceLocator.Object);

            Act();
        }
Beispiel #34
0
 public void StoreWithDefaultTranscoder()
 {
     var config = GetConfig();
     SomeType obj = new SomeType { Id = 1, Name = "abc" }, clone;
     using (var client = new MemcachedClient(config))
     {
         client.Store(StoreMode.Set, "raw1", obj);
     }
     using (var client = new MemcachedClient(config))
     {
         clone = (SomeType) client.Get("raw1");
     }
     Assert.AreEqual(1, clone.Id);
     Assert.AreEqual("abc", clone.Name);
 }
Beispiel #35
0
        public void SerializeFileTest()
        {
            var item1 = new SomeType { Id = "1", Value = "A", Values = new List<string> { "aaa", "bbb", "ccc" } };
            var item2 = new SomeType { Id = "2", Value = "B", Values = new List<string> { "ddd", "eee", "fff" } };

            var store = Storage.GetStore();

            store.Dictionary.Clear();
            store.Set(item1);
            store.Set(item2);
            store.Dictionary.Export("file.json");
            store.Dictionary.Clear();
            Assert.AreEqual(0, store.Dictionary.Count);
            store.Dictionary.Import("file.json");

            Assert.AreEqual(2, store.Dictionary.Count);

            var fetchedItem1 = store.Get<SomeType>(item1.Id);
            var fetchedItem2 = store.Get<SomeType>(item2.Id);

            Assert.AreEqual(item1.Values[2], fetchedItem1.Values[2]);
            Assert.AreEqual(item2.Values[2], fetchedItem2.Values[2]);
        }
 private void Act()
 {
     _actualResult = _sut.Get<SomeType>();
 }
Beispiel #37
0
            public void Given()
            {
                var source = new SomeType("str", new SomeNestedType(new SomeNestedType(null, "str2"), "str3"), new[] { 342, 456, 23}, 666 );
                var cloned = source.DeepClone();

                _source = source;
                _cloned = cloned;
            }